// array:1 [▼
// "rajaongkir" => array:5 [▼
// "query" => array:6 [▼
// "origin" => "501"
// "originType" => "city"
// "destination" => "574"
// "destinationType" => "subdistrict"
// "weight" => 1700
// "courier" => "sicepat"
// ]
// "status" => array:2 [▼
// "code" => 200
// "description" => "OK"
// ]
// "origin_details" => array:6 [▼
// "city_id" => "501"
// "province_id" => "5"
// "province" => "DI Yogyakarta"
// "type" => "Kota"
// "city_name" => "Yogyakarta"
// "postal_code" => "55111"
// ]
// "destination_details" => array:7 [▼
// "subdistrict_id" => "574"
// "province_id" => "10"
// "province" => "Jawa Tengah"
// "city_id" => "41"
// "city" => "Banyumas"
// "type" => "Kabupaten"
// "subdistrict_name" => "Banyumas"
// ]
// "results" => array:1 [▼
// 0 => array:3 [▼
// "code" => "sicepat"
// "name" => "SiCepat Express"
// "costs" => array:3 [▼
// 0 => array:3 [▼
// "service" => "REG"
// "description" => "Layanan Reguler"
// "cost" => array:1 [▼
// 0 => array:3 [▼
// "value" => 34000
// "etd" => "4-5"
// "note" => ""
// ]
// ]
// ]
// 1 => array:3 [▼
// "service" => "SIUNT"
// "description" => "SiUntung"
// "cost" => array:1 [▼
// 0 => array:3 [▼
// "value" => 30000
// "etd" => "4-5"
// "note" => ""
// ]
// ]
// ]
// 2 => array:3 [▼
// "service" => "GOKIL"
// "description" => "Cargo (Minimal 10kg)"
// "cost" => array:1 [▼
// 0 => array:3 [▼
// "value" => 40000
// "etd" => "4-6"
// "note" => ""
// ]
// ]
// ]
// ]
// ]
// ]
// ]
// ]
// response
I want to get a value from an API, with Arr::get helper, but with given this array,
I even try to take the "origin:501" value would expect "501" but it also returns null,
let’s say if I want to get the deepest array element "value" , should not it be like this?
$value = Arr::get($array,'rajaongkir.results.0.costs.0.cost.0.value');
expect the $value should be 34000 , but it returns null, why?
Source: Laravel