3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = <<< EOT <?xml version='1.0' encoding='UTF-8'?> <response> <apiKey id="1" apikey="1474C404-1DB4-4EA0-B2C2-516E86CB4F69">API key ok.</apiKey> <apiKeyMessage>...</apiKeyMessage> <Configuration VisibileToDeveloper="True">...</Configuration> <propertySearchSales> <properties rentalperiod="0"> <pages page="1" count="6" pageCount="1" perPage="10"> <page number="1" selected="true"/> </pages> <property id="2225088" eaid="1221" bid="1953" rescomnew="1" longitude="33.0225" latitude="34.70676" dateSTC="" dateInstructed="18/07/2011" featured="false" price="€26,000" priceVal="26000" currency="EUR" rentalperiod="1" updated="19/9/2013 14:25:59" bedrooms="3" bathrooms="0" receptions="0" garages="0" gardens="0" otherrooms="0" specials="0" parkingSpaces="0" metropix="0" virturaltour="" propertyType="57" hits="2827" leaseType="1" EATel="00357 99 207000" period="Not Applicable" sold="0" UO_LA="false" picture="true" EER_Current="0" EER_Potential="0" EIR_Current="0" EIR_Potential="0" portfolio="false">...</property> <property id="2242068" eaid="1221" bid="1953" rescomnew="1" longitude="0" latitude="0" dateSTC="" dateInstructed="18/07/2011" featured="false" price="€29,770" priceVal="29770" currency="EUR" rentalperiod="1" updated="17/8/2011 08:55:20" bedrooms="3" bathrooms="0" receptions="0" garages="0" gardens="0" otherrooms="0" specials="0" parkingSpaces="0" metropix="0" virturaltour="" propertyType="57" hits="2707" leaseType="1" EATel="00357 99 207000" period="Not Applicable" sold="0" UO_LA="false" picture="true" EER_Current="0" EER_Potential="0" EIR_Current="0" EIR_Potential="0" portfolio="false">...</property> <property id="2242067" eaid="1221" bid="1953" rescomnew="1" longitude="33.0225" latitude="34.70676" dateSTC="" dateInstructed="18/07/2011" featured="false" price="€31,200" priceVal="31200" currency="EUR" rentalperiod="1" updated="19/9/2013 14:26:27" bedrooms="3" bathrooms="0" receptions="0" garages="0" gardens="0" otherrooms="0" specials="0" parkingSpaces="0" metropix="0" virturaltour="" propertyType="57" hits="2810" leaseType="1" EATel="00357 99 207000" period="Not Applicable" sold="0" UO_LA="false" picture="true" EER_Current="0" EER_Potential="0" EIR_Current="0" EIR_Potential="0" portfolio="false">...</property> <property id="2242066" eaid="1221" bid="1953" rescomnew="1" longitude="0" latitude="0" dateSTC="" dateInstructed="18/07/2011" featured="false" price="€31,525" priceVal="31525" currency="EUR" rentalperiod="1" updated="18/7/2011 13:43:07" bedrooms="3" bathrooms="0" receptions="0" garages="0" gardens="0" otherrooms="0" specials="0" parkingSpaces="0" metropix="0" virturaltour="" propertyType="57" hits="2705" leaseType="1" EATel="00357 99 207000" period="Not Applicable" sold="0" UO_LA="false" picture="true" EER_Current="0" EER_Potential="0" EIR_Current="0" EIR_Potential="0" portfolio="false">...</property> <property id="2241909" eaid="1221" bid="1953" rescomnew="1" longitude="0" latitude="0" dateSTC="" dateInstructed="18/07/2011" featured="false" price="€31,850" priceVal="31850" currency="EUR" rentalperiod="1" updated="13/3/2013 06:37:23" bedrooms="3" bathrooms="0" receptions="0" garages="0" gardens="0" otherrooms="0" specials="0" parkingSpaces="0" metropix="0" virturaltour="" propertyType="57" hits="2803" leaseType="1" EATel="00357 99 207000" period="Not Applicable" sold="0" UO_LA="false" picture="true" EER_Current="0" EER_Potential="0" EIR_Current="0" EIR_Potential="0" portfolio="false">...</property> <property id="2242117" eaid="1221" bid="1953" rescomnew="1" longitude="0" latitude="0" dateSTC="" dateInstructed="18/07/2011" featured="false" price="€33,345" priceVal="33345" currency="EUR" rentalperiod="1" updated="18/7/2011 13:20:26" bedrooms="3" bathrooms="0" receptions="0" garages="0" gardens="0" otherrooms="0" specials="0" parkingSpaces="0" metropix="0" virturaltour="" propertyType="57" hits="2701" leaseType="1" EATel="00357 99 207000" period="Not Applicable" sold="0" UO_LA="false" picture="true" EER_Current="0" EER_Potential="0" EIR_Current="0" EIR_Potential="0" portfolio="false">...</property> <searchParameters minPrice="0" maxPrice="99999999" branchList="" eaid="1221" propertyType="" listDefsPropertyType="" bedrooms="0" bathrooms="0" receptions="0" garages="0" gardens="0" parkingSpaces="0" showSTC="" allAddressFields="Croatia" sa1="" sa2="" town="" city="" county="" postcode="" location="" locationAND="" classification="" descending="" currency="" page="1" perPage="10" sessionGUID="53b8fbf5-6a0e-4f3e-a703-a0fbcdaf7606"/> </properties> </propertySearchSales> </response> EOT; $simpleXML = simplexml_load_string($xml); // Load XML string data into the simplexml object parser foreach ($simpleXML->result->rowset->row as $row) { $titles = []; $name = $row['name']->__toString(); foreach($row as $attrib){ if($attrib['name']->__toString() === 'titles'){ foreach($attrib as $title){ $titles[] = $title['titleName']->__toString(); } } } echo $name . ' : ' . implode(' - ', $titles) . "<br/>\n"; }
based on Bsqn5
Output for 5.4.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Trying to get property of non-object in /in/iiNQb on line 27 Warning: Invalid argument supplied for foreach() in /in/iiNQb on line 27
Output for hhvm-3.10.0 - 3.12.0
Notice: Cannot access property on non-object in /in/iiNQb on line 27 Warning: Invalid argument supplied for foreach() in /in/iiNQb on line 38
Output for 4.4.3 - 4.4.9, 5.1.0 - 5.1.1, 5.1.3 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/iiNQb on line 28
Process exited with code 255.
Output for 4.4.2, 5.1.2
Parse error: syntax error, unexpected '[' in /in/iiNQb on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/iiNQb on line 28
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/iiNQb on line 28
Process exited with code 255.