3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array('idproduct' => 1, 'amount' => 5), array('idproduct' => 2, 'amount' => 10), array('idproduct' => 3, 'amount' => 11), array('idproduct' => 4, 'amount' => 5) ); addOrOverride($arr, array('idproduct' => 4, 'amount' => 5)); function addOrOverride($arr, $newItem) { $filtered = array_filter(function($item) { $item['idproduct'] != $newItem['idproduct']; }, $arr) if($filtered) die('exists'); }
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected 'if' (T_IF) in /in/A1K09 on line 16
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_IF in /in/A1K09 on line 16
Process exited with code 255.

preferences:
184.62 ms | 935 KiB | 65 Q