3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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);
based on QYs6p
Output for 5.2.0 - 7.2.0
{"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.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.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