How do I set the name or name1 variable to value of the $event's name attribute? When I step through the code name equals a simplexmlobject with no value and name2 is null.
$name3 = $event->attributes()->name; does not work either.
I am confused on how to use this properly.
$curl = curl_init();
curl_setopt_array($curl, Array(
CURLOPT_URL => 'http://odds.smarkets.com/oddsfeed.xml',
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_ENCODING => 'UTF-8'
));
$data = curl_exec($curl);
curl_close($curl);
$xml = simplexml_load_string($data);
$football = array();
foreach($xml->event as $event){
if($event->attributes()->type == "Football match"){
$att = $event->attributes();
$name = $att['name'];
$name2 = $att->attributes()->name;
$name3 = $event->attributes()->name;
$football[] = $event;
}
}
foreach($football as $game){
if($game->attributes()->name == "Sunderland vs. Manchester United"){
$a = $game;
}
}