3v4l.org

run code in 300+ PHP versions simultaneously
<?php $cart = [ [ 'productID' => '11111' , 'size' => 'M' , 'quantity' => 2 ], [ 'productID' => '11111' , 'size' => 'L' , 'quantity' => 4 ], [ 'productID' => '22222' , 'size' => 'S' , 'quantity' => 3 ], [ 'productID' => '22222' , 'size' => 'L' , 'quantity' => 7 ], [ 'productID' => '33333' , 'size' => 'M' , 'quantity' => 1 ] ]; $r = removeElementFromArray( $cart , [ 'productID' => '11111' , 'size' => 'M' ] ); print_r($r); function removeElementFromArray($targetArray, $needles) { return array_filter($targetArray, function ($item) use ($needles) { return !empty(array_diff_assoc($needles, $item)); }); }

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
157.31 ms | 2251 KiB | 13 Q