php - how to pass value of varibles in json -


foreach ($orderslist $object) {      $entityid = $object->entity_id; //how give $entityid in json      $json='{     "orderno":$entityid,          //here want assign value of $entityid     "customercode": $customerid,     "dateordered": "08-07-2015",     "warehouseid" : ,     "orderlinelist":     [      "productid": 1000002,     "qty": 6,     "price": 10     ]     }'; }  $data = json_decode($json); $data_string=  json_encode($data); 

don't write json strings hand.

$data = [     "orderno" => $entityid, //here want assign value of $entityid     "customercode" =>  $customerid,     "dateordered" => "08-07-2015",     "warehouseid" => null ,     "orderlinelist" => [         "productid": 1000002,         "qty": 6,         "price": 10,     ], ];  $json = json_encode($data); 

json_decode() give error this:

{"orderlinelist": [ "productid": 1000002 ]} 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -