array(3) { [0]=> array(1) { ["id"]=> int(852) } [1]=> array(1) { ["id"]=> int(853) } [2]=> array(1) { ["id"]=> int(854) } }
How to add an id of 845 to such an array and then turn the array into a string of 852,853,854, 845?
$arr=[['id'=>852],['id'=>853],['id'=>854]]; foreach ($arr as $key => $value) { $new[]=implode('',$value); } $new[]='845'; $new=implode(',',$new); var_dump($new);
$ARR [] = ['id'=>845];The subsequent transformation was answered downstairs
$arr = array( array('id' => 852), array('id' => 853), array('id' => 854), ); $arr[] = array('id' => 845); $arr = array_column($arr, 'id'); $str = implode(',', $arr); var_dump($str);
The same error message is reported when you run it alone
$ARR [] = ['id'=>845];
The subsequent transformation was answered downstairs
The same error message is reported when you run it alone