3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $duty = array(); $duty['quantity'] = 1; $duty['sku'] = '20-76-01-0040-000-000'; $duty['name'] = 'Duties'; $duty['price'] = array( "amountExcludingTax" => 12.99, "amountIncludingTax" => 12.99, "tax" => 0 ); $data['rows'][] = $duty; $service = array(); $service['quantity'] = 1; $service['sku'] = '20-76-01-0050-000-000'; $service['name'] = 'Service Fees'; $service['price'] = array( "amountExcludingTax" => 20.50, "amountIncludingTax" => 20.50, "tax" => 0 ); $data['rows'][] = $service; echo json_encode($data);
based on Ec0Mr
Output for 5.6.0 - 5.6.30, hhvm-3.18.5 - 3.22.0, 7.1.0 - 7.3.0beta1
{"rows":[{"quantity":1,"sku":"20-76-01-0040-000-000","name":"Duties","price":{"amountExcludingTax":12.99,"amountIncludingTax":12.99,"tax":0}},{"quantity":1,"sku":"20-76-01-0050-000-000","name":"Service Fees","price":{"amountExcludingTax":20.5,"amountIncludingTax":20.5,"tax":0}}]}