3v4l.org

run code in 500+ PHP versions simultaneously
<?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);
Output for git.master, git.master_jit, rfc.property-hooks
array(4) { [0]=> array(4) { [0]=> int(0) [1]=> int(1) [2]=> int(1) [3]=> int(0) } [1]=> array(4) { [0]=> int(1) [1]=> int(1) [2]=> int(1) [3]=> int(1) } [2]=> array(4) { [0]=> int(1) [1]=> int(1) [2]=> int(1) [3]=> int(1) } [3]=> array(4) { [0]=> int(0) [1]=> int(1) [2]=> int(1) [3]=> int(0) } }

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:
52.86 ms | 1336 KiB | 4 Q