3v4l.org

run code in 500+ PHP versions simultaneously
<?php class LogParser { public static function getIdsByMessage($xml, $message) { $matches = array(); $xml_parsed = simplexml_load_string($xml); foreach($xml_parsed as $item) { if($item->message == $message) { $attributes = $item->attributes(); $matches[] = (string) $attributes['id']; } } return $matches; } } $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <log> <entry id="1"> <message>Application started</message> </entry> <entry id="2"> <message>Application ended</message> </entry> </log> XML; print_r(LogParser::getIdsByMessage($xml, 'Application ended'));
Output for rfc.property-hooks, git.master, git.master_jit
Array ( [0] => 2 )

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:
92.79 ms | 2687 KiB | 4 Q