Replacing a Text String that is being pulled from xml in a php script

Hello Everyone,

I have a minor problem that is bugging the crap out of me at the moment.

I have written a script to pull data from the Vatsim datafeed and want the $objects->callsign part replaced if the string EDWW_B_CTR is returned. I would like to replace EDWW_B_CTR with Bremen Radar in the table.

Any help would be greatly appreciated.

[code]

.centertext { text-align: center; } .font { font-family: Arial; font-size: 12px; color: #000000; }
<?php // load SimpleXML $objects = new SimpleXMLElement('http://api.vateud.net/online/atc/EDAB,EDAC,EDAG,EDAH,EDAK,EDAU,EDAV,EDAY,EDAZ,EDBC,EDBH,EDBK,EDBM,EDBW,EDBY,EDCA,EDCD,EDCG,EDCJ,EDCM,EDCP,EDCS,EDDB,EDDC,EDDE,EDDI,EDDP,EDDT,EDOP,EDUB,EDUW,ENTL,ETNU,ETSH,EDBB,EDWW_B_CTR,EDMM_S_CTR,EDMM_T_CTR.xml', null, true);

echo <<<EOF

EOF;
foreach($objects as $object) // loop through our books
{
echo <<<EOF

            <td width="33%" align="center" valign="middle" nowrap="nowrap" bgcolor="#ffffff"><span class="data">$object->callsign</span></td>
            <td width="33%" align="center" valign="middle" nowrap="nowrap" bgcolor="#ffffff"><span class="data">$object->frequency</span></td>
            <td width="33%" align="center" valign="middle" nowrap="nowrap" bgcolor="#ffffff"><span class="data">$object->name</span></td>
    </tr>

EOF;
}
echo ‘

Callsign Frequency Name
’;
?> [/code]

I would do it like this. Also changing from echoing out html to echoing php variables inside html. It makes for much better readability in most IDEs.

[php]<?php
// load SimpleXML
$objects = new SimpleXMLElement(‘http://api.vateud.net/online/atc/EDAB,EDAC,EDAG,EDAH,EDAK,EDAU,EDAV,EDAY,EDAZ,EDBC,EDBH,EDBK,EDBM,EDBW,EDBY,EDCA,EDCD,EDCG,EDCJ,EDCM,EDCP,EDCS,EDDB,EDDC,EDDE,EDDI,EDDP,EDDT,EDOP,EDUB,EDUW,ENTL,ETNU,ETSH,EDBB,EDWW_B_CTR,EDMM_S_CTR,EDMM_T_CTR.xml’, null, true);
?>

.centertext { text-align: center; } .font { font-family: Arial; font-size: 12px; color: #000000; }
<?php foreach($objects as $object) // loop through our books { ?>
             <td width="33%" align="center" valign="middle" nowrap="nowrap" bgcolor="#ffffff"><span class="data"><?= $object->callsign == 'EDWW_B_CTR' ? 'Bremen Radar' : $object->callsign ?></span></td>
             <td width="33%" align="center" valign="middle" nowrap="nowrap" bgcolor="#ffffff"><span class="data"><?= $object->frequency ?></span></td>
             <td width="33%" align="center" valign="middle" nowrap="nowrap" bgcolor="#ffffff"><span class="data"><?= $object->name ?></span></td>
     </tr>
<?php } ?>
Callsign Frequency Name
[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service