3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{ "provider_id":1, "nro_chart":1, "control": { "color": "blue", "total_value": 21.5, "car_id": 421118 } }, { "control": { "color": "green", "total_value": 25, "car_id": 421119 } }, { "control": { "color": "red", "total_value": 18, "car_id": 421519 } } ]'; $array = json_decode($json,true); // decode as array //list($provider_id,$nro_chart)=array_values(array_splice($array[0],0,2)); // extract and declare single occurrence values $provider_id=$array[0]['provider_id']; $nro_chart=$array[0]['nro_chart']; foreach($array as $index=>&$subarray){ $subarray=['total_value'=>$subarray['control']['total_value'],'car_id'=>$subarray['control']['car_id']]; } echo "provider_id = $provider_id\n"; // display integer value echo "nro_chart = $nro_chart\n"; // display integer value var_export($array); // display updated array
Output for git.master, git.master_jit, rfc.property-hooks
provider_id = 1 nro_chart = 1 array ( 0 => array ( 'total_value' => 21.5, 'car_id' => 421118, ), 1 => array ( 'total_value' => 25, 'car_id' => 421119, ), 2 => array ( 'total_value' => 18, 'car_id' => 421519, ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
42 ms | 401 KiB | 8 Q