3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ 0 => [ "user_type" => 'Manager', "total_count" => 3, ], 1 => [ "user_type" => 'Director', "total_count" => 2, ], ]; /** * @param array $a */ function pr($a = []) { echo "<pre>"; print_r($a); echo "</pre>"; } $arr = array_combine(['labels','dataset'],array_map(null, ...$arr)); if(!in_array('Trainee',$arr['labels'])){ array_push($arr['labels'],'Trainee'); array_push($arr['dataset'],0); } print_r($arr);die;

preferences:
34.29 ms | 408 KiB | 5 Q