3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = '<?xml version="1.0" encoding="utf-8" ?> <note> <to> <form>pswA</form> <heading>A</heading> </to> <to> <form>pswB</form> <heading>A</heading> </to> </note>'; $xml = simplexml_load_string($data); foreach ($xml->to as $to){ if ($to->form == 'pswA' && $to->heading == 'A'){echo "allow";} elseif ($to->form == 'pswA' && $to->heading == 'B'){echo "notallow";} elseif ($to->form == 'pswA' && $to->heading == 'C'){echo "block";} } ob_start(); foreach ($xml->to as $to){ if ($to->form == 'pswA' && $to->heading == 'A') echo "allow"; elseif ($to->form == 'pswC' && $to->heading == 'B') echo "notallow"; elseif ($to->form == 'pswC' && $to->heading == 'C') echo "block"; } if(!ob_get_contents()) echo "empty"; ob_end_flush(); ?>

preferences:
54.48 ms | 402 KiB | 5 Q