3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array1 = ["banana","car","carrot"]; $needle = "car"; if (($index = array_search($needle, $array1)) !== false) { $array2[] = $array1[$index]; unset($array1[$index]); } var_export($array1); echo "\n---\n"; var_export($array2);

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
151.58 ms | 2554 KiB | 10 Q