<?php $arr = [ 0 => [0, 0 , 0 , 0], 1 => [0, 1 , 0 , 0], 2 => [0, 0 , 1 , 0], 3 => [0, 0 , 0 , 0], ]; $new = []; foreach($arr as $r => $row){ foreach($row as $c => $val){ $new[$r][$c] = (in_array(1,$row) OR in_array(1,array_column($arr,$c))) ? 1 : 0; } } var_dump($new);
You have javascript disabled. You will not be able to edit any code.