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;
Output for rfc.property-hooks, git.master, git.master_jit
6514

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
47.9 ms | 1465 KiB | 4 Q