3v4l.org

run code in 300+ PHP versions simultaneously
<?php $partner_array = array( 'PartnerId' => '6729', ); $partner = (object) $partner_array; $buyer_array = array( 'Email' => 'escrow.buyer@hotmail.com', 'Initiator' => 'false', 'CompanyChk' => 'false', 'AutoAgree' => 'false', 'AgreementChecked' => 'false', ); $buyer = (object) $buyer_array; $seller_array = array( 'Email' => 'escrow.seller@hotmail.com', 'Initiator' => 'false', 'CompanyChk' => 'false', 'AutoAgree' => 'false', 'AgreementChecked' => 'false', ); $seller = (object) $seller_array; $broker_array = array( 'Email' => 'escrow.broker@hotmail.com', 'Initiator' => 'true', 'CompanyChk' => 'true', 'AutoAgree' => 'true', 'AgreementChecked' => 'true', ); $broker = (object) $broker_array; // This array contains objects, which container the inner array $line_items_container_array = array(); // Holds data about the line item $line_items_inner_array = array( 'ItemName' => 'Line item 1', 'Description' => 'REST Service test line item', 'Quantity' => '1', 'Price' => '2500', 'Accept' => 'true', 'SellComm' => '100', 'BuyComm' => '50', ); $line_items = (object) $line_items_inner_array; $line_items_container_array[] = $line_items; $json_array = array( 'Title' => 'JSON GM Broker Transaction (REST Service)', 'Description' => 'JSON GM Broker Transaction (REST Service)', 'TransactionType' => '1', 'EscrowPayment' => '0', 'ShipmentFee' => '25', 'ShipmentPayment' => '0', 'InspectionLength' => '6', 'Currency' => 'USD', 'Fulfillment' => '1', 'Disclosure' => '1', 'BrokerCommissionPayee' => 'Buyer', 'BrkCommissionBuyerPortion' => '18.1', 'BrkCommissionSellerPortion' => '19.1', 'CommissionType' => '1', 'InitiationDate' => '2014-04-15', 'TransactionLocked' => 'true', 'PartnerTransID' => '12345', 'TermsLocked' => 'true', 'AllowReject' => 'true', 'Partner' => $partner, 'Buyer' => $buyer, 'Seller' => $seller, 'Broker' => $broker, 'LineItems' => $line_items_container_array, ); $json = json_encode($json_array); print_r($json);
Output for 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
{"Title":"JSON GM Broker Transaction (REST Service)","Description":"JSON GM Broker Transaction (REST Service)","TransactionType":"1","EscrowPayment":"0","ShipmentFee":"25","ShipmentPayment":"0","InspectionLength":"6","Currency":"USD","Fulfillment":"1","Disclosure":"1","BrokerCommissionPayee":"Buyer","BrkCommissionBuyerPortion":"18.1","BrkCommissionSellerPortion":"19.1","CommissionType":"1","InitiationDate":"2014-04-15","TransactionLocked":"true","PartnerTransID":"12345","TermsLocked":"true","AllowReject":"true","Partner":{"PartnerId":"6729"},"Buyer":{"Email":"escrow.buyer@hotmail.com","Initiator":"false","CompanyChk":"false","AutoAgree":"false","AgreementChecked":"false"},"Seller":{"Email":"escrow.seller@hotmail.com","Initiator":"false","CompanyChk":"false","AutoAgree":"false","AgreementChecked":"false"},"Broker":{"Email":"escrow.broker@hotmail.com","Initiator":"true","CompanyChk":"true","AutoAgree":"true","AgreementChecked":"true"},"LineItems":[{"ItemName":"Line item 1","Description":"REST Service test line item","Quantity":"1","Price":"2500","Accept":"true","SellComm":"100","BuyComm":"50"}]}
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/YqRK8 on line 77
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/YqRK8 on line 77
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/YqRK8 on line 77
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/YqRK8 on line 77

preferences:
245.52 ms | 401 KiB | 365 Q