what is syntax of destructure of this array?
<?php $arr = [ [1,2,4], [4,2,6], [2,1,8] ]; ?>Maybe I don’t understand what do you wish to accomplish, but this works as expected, assigning all 9 $cell… variables.
[
[$cell00, $cell01, $cell02],
[$cell10, $cell11, $cell12],
[$cell20, $cell21, $cell22]
] = $arr;
Or you can get the 1D row arrays by
[$row0, $row1, $row2] = $arr;
Or if you meant flattening the array (making an 1D version), try this:
$flat = call_user_func_array('array_merge', $arr);
(However, this is not called ‘destructuring’.)
PS: From PHP v8.1 the last one can be also written in a slightly more idiomatic way:
$flat = call_user_func_array(array_merge(...), $arr);
thanks
[$row0, $row1, $row2] = $arr;
```works ,
and $cell method works too