3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xmlString = '<HybridSchedule> <matchNumber>1</matchNumber> <scoreBlueFinal>260</scoreBlueFinal> <scoreRedFinal>135</scoreRedFinal> <startTime>2017-03-25T10:30:00</startTime> <Teams> <Team> <station>Red1</station> <teamNumber>6514</teamNumber> </Team> <Team> <station>Red2</station> <teamNumber>1285</teamNumber> </Team> </Teams> </HybridSchedule>'; // If you have the XML as a string in a variable $xml = simplexml_load_string($xmlString); $teamNumber = null; foreach ($xml->Teams->Team as $team) { if ($team->station == 'Red1') { // We need to cast it as an int, or we're going to end up // with a "SimpleXMLElement"-object. $teamNumber = (int) $team->teamNumber; // We found our item, let's stop iterating break; } } echo $teamNumber;

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
149.61 ms | 2089 KiB | 9 Q