3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array ( 0 => array ( 'norm_value' => 2.5, ), 1 => array ( 'norm_value' => 7.01, ), 2 => array ( 'norm_value' => 0.0, ), 3 => array ( 'norm_value' => 4.167, ), 4 => array ( 'norm_value' => 0.0, ), ), array ( 0 => array ( 'norm_value' => 0.0, ), 1 => array ( 'norm_value' => 0.0, ), 2 => array ( 'norm_value' => 0.0, ), 3 => array ( 'norm_value' => 1.267, ), 4 => array ( 'norm_value' => 0.0, ), ), array ( 0 => array ( 'norm_value' => 0.0, ), 1 => array ( 'norm_value' => 0.0, ), 2 => array ( 'norm_value' => 0.0, ), 3 => array ( 'norm_value' => 0.0, ), 4 => array ( 'norm_value' => 0.0, ), ), array ( 0 => array ( 'norm_value' => 3.54, ), 1 => array ( 'norm_value' => 2.04, ), 2 => array ( 'norm_value' => 0.673, ), 3 => array ( 'norm_value' => 8.546, ), 4 => array ( 'norm_value' => 0.0, ), ) ); $epsilon = 0.00001; foreach($arr as $index => $subarray){ $count = 0; foreach($subarray as $norm_data){ if(abs($norm_data['norm_value'] - 0.0) < $epsilon) $count++; } if($count === count($subarray) || $count == count($subarray)-1){ unset($arr[$index]); } } print_r($arr);
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Array ( [0] => Array ( [0] => Array ( [norm_value] => 2.5 ) [1] => Array ( [norm_value] => 7.01 ) [2] => Array ( [norm_value] => 0 ) [3] => Array ( [norm_value] => 4.167 ) [4] => Array ( [norm_value] => 0 ) ) [3] => Array ( [0] => Array ( [norm_value] => 3.54 ) [1] => Array ( [norm_value] => 2.04 ) [2] => Array ( [norm_value] => 0.673 ) [3] => Array ( [norm_value] => 8.546 ) [4] => Array ( [norm_value] => 0 ) ) )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
219.67 ms | 408 KiB | 5 Q