3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = '<?xml version="1.0" encoding="utf-8"?><ResponseXML xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="GenericVO.CardEnquiry"><ReturnStatus>1</ReturnStatus><ReturnMessage>SUCCESS</ReturnMessage><RequestTime>20150430151542</RequestTime><ResponseTime>20150430151543</ResponseTime><CardInfo><CardNo>9999000000072720</CardNo><MemberID>2422732</MemberID><PrintedName>Xiaoheng Wang</PrintedName><MembershipTypeCode>MSR</MembershipTypeCode><MembershipStatusCode>ACTIVE</MembershipStatusCode><MembershipPhoto /><IssueDate>2015-03-26T00:00:00</IssueDate><EffectiveDate>2015-03-26T00:00:00</EffectiveDate><ExpiryDate>2016-03-26T00:00:00</ExpiryDate><Printed>false</Printed><PrintedDate xsi:nil="true" /><RenewedDate xsi:nil="true" /><tmpEffectiveDate xsi:nil="true" /><tmpExpiryDate xsi:nil="true" /><tmpMembershipStatusCode /><PointsBAL>5.0000</PointsBAL><TotalPointsBAL>5.0000</TotalPointsBAL><HoldingPoints>0</HoldingPoints><Remarks /><MembershipDiscount xsi:nil="true" /><TierCode>Welcome</TierCode><LoyaltyMessage>for-iCare-8898XXXXXXXXXXXX</LoyaltyMessage><DollarToPointsRatio /><RewardCycleLists><RewardCycleInfo Type="Current" Value="5.0000" ExpiringDate="2016-03-26T00:00:00" /></RewardCycleLists><IsSupplementary>false</IsSupplementary><isBurnSupplementaryCard>false</isBurnSupplementaryCard><RelationID>188559A7-9B25-486A-9989-4F9D1EFA5771</RelationID><PrimaryCardNo /><PrimaryRelationID /><PrimaryCardExpiryDate xsi:nil="true" /><PrimaryCardEffectiveDate xsi:nil="true" /><PtsHoldingDays>0</PtsHoldingDays><Passcode>75310179 </Passcode><StoredValueBalance>0.0000</StoredValueBalance><Currency /><LastVisitedDate>2015-04-26T00:00:00</LastVisitedDate><LastVisitedOutlet>518</LastVisitedOutlet><PointsToNextTier /><NettToNextTier /></CardInfo><MemberInfo><MemberID>2422732</MemberID><Salutation /><Name>Xiaoheng Wang</Name><NRIC /><Passport /><Email>wangxiaoheng0319@gmail.com</Email><Gender>F</Gender><DOB>1992-03-19T00:00:00</DOB><Nationality /><Block /><Level /><Unit /><Street /><Building /><PostalCode /><Country /><Address1> </Address1><Address2> </Address2><Address3> </Address3><ContactNo /><MobileNo>93585185</MobileNo><FaxNo /><ReferrerCode /><FacebookID /><FacebookName /><FacebookPhotoLink /><FacebookToken /><FacebookTokenExpiry /><FullPhotoName /><Base64PhotoString /><PhotoLink /></MemberInfo><MembershipInfo><TotalSpending>8.2</TotalSpending><TotalPoints>5</TotalPoints><TotalVisits>1</TotalVisits><LastVisitedOutletCode>518</LastVisitedOutletCode><MostCycleVisitedOutletCode>518</MostCycleVisitedOutletCode><TotalCycleVisits>1</TotalCycleVisits><TotalCycleSpending>8.2</TotalCycleSpending><TotalCyclePoints>5</TotalCyclePoints><TotalBalPoints>5</TotalBalPoints><CurrentMonthSpending>8.2</CurrentMonthSpending><CurrentMonth_1Spending>0</CurrentMonth_1Spending><CurrentMonth_2Spending>0</CurrentMonth_2Spending><TotalNettSpending>8.2</TotalNettSpending><TotalCycleNettSpending>8.2</TotalCycleNettSpending><CurrentMonthNettSpending>8.2</CurrentMonthNettSpending><CurrentMonth_1NettSpending>0</CurrentMonth_1NettSpending><CurrentMonth_2NettSpending>0</CurrentMonth_2NettSpending></MembershipInfo><TotalActiveVoucherCount>0</TotalActiveVoucherCount><VoucherLists /><ReceiptMessage>Card No : 9999000000072720 Tier : Welcome Stars Awarded: 0 Stars Balance: 5 Stored Value Balance: 0.0000 </ReceiptMessage></ResponseXML>'; $response = htmlspecialchars_decode($data); //echo $response;exit; $res = preg_replace('/xmlns[^=]*="[^"]*"/i', '', $response); // remove all namespaces $res = preg_replace('/xsi:nil="true"/i', '', $res); // remove all xsi:nil="true" $xml = simplexml_load_string($res); $cardsArray = array(); $cardsStatus = array(); $counter = 0; foreach ($xml->CardLists->children()->CardInfo as $child) { // primary card, IsSupplementary == false if ($child->IsSupplementary == 'false') { $_SESSION['MainCard'] = (string) $child->CardNo; $_SESSION['TierCode'] = (string) $child->TierCode; $_SESSION["PointsTier"] = (string) $child->PointsToNextTier; $_SESSION["IssueDate"] = (string) $child->IssueDate; echo $child;exit; } else { //get supp cards if ($child->MembershipStatusCode == 'ACTIVE') { $cardsArray[$counter] = (string) $child->CardNo; $cardsStatus[$counter] = (string) $child->MembershipStatusCode; $counter++; } } }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: Attempt to read property "CardInfo" on null in /in/TkIRJ on line 17 Warning: foreach() argument must be of type array|object, null given in /in/TkIRJ on line 17
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Warning: Attempt to read property "CardInfo" on null in /in/TkIRJ on line 17 Warning: foreach() argument must be of type array|object, null given in /in/TkIRJ on line 17
Output for 5.1.0 - 5.1.2, 5.2.1 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.10, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: main(): Node no longer exists in /in/TkIRJ on line 17 Warning: Invalid argument supplied for foreach() in /in/TkIRJ on line 17
Output for 5.1.3 - 5.1.6, 5.2.0
Warning: main(): Node no longer exists in /in/TkIRJ on line 17 Warning: main(): Node no longer exists in /in/TkIRJ on line 17 Warning: main(): Node no longer exists in /in/TkIRJ on line 17 Warning: main(): Node no longer exists in /in/TkIRJ on line 17
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function htmlspecialchars_decode() in /in/TkIRJ on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/TkIRJ on line 17
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/TkIRJ on line 17
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/TkIRJ on line 17
Process exited with code 255.

preferences:
206.71 ms | 401 KiB | 310 Q