mercredi 9 décembre 2020

How to convert js nested object to php array

I am trying to convert js object in php array it is working but inside that object there are more objects which also need to convert in array

here is how i am converting

$data = json_decode($order->data,true);
           dd($data);

result

array:12 [
  "paymethod_id" => 1
  "business_id" => 76
  "delivery_type" => "1"
  "driver_tip" => 0
  "delivery_zone_id" => 6569
  "delivery_datetime" => null
  "location" => array:2 [
    "lat" => 18.7675049
    "lng" => -103.1445221
  ]
  "deliveryOptionmodal" => array:3 [
    "id" => 2
    "value" => "Esperar en la entrada"
    "$$hashKey" => "object:525"
  ]
  "delivery_cost_new" => 20
  "products" => "[{"id":48732,"code":"NPxRSw","quantity":1,"options":[],"ingredients":[]}]"
  "customer_id" => 129731
  "customer" => "{"id":129731,"name":"bil","middle_name":null,"lastname":"ar","second_lastname":null,"photo":null,"email":"bilal1212@gmail.com","cellphone":"0213123132131","address":"Coalcomán, Michoacán, Mexico","location":"{\"lat\":18.7675049,\"lng\":-103.1445221}","internal_number":null,"address_notes":"sss","zipcode":null,"map_data":{"library":"google","place_id":"ChIJz6WGrUw-MIQR_jYIoFZ-RPM"},"tag":"home"}"
]

You can see customer and product object is not converted into array how i can do that?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire