3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 'a' => 'food', 'b' => 'foo', 'c' => 'goo', 'd' => 'foo', 'e' => 'good' ]; $needle = 'foo'; $newValue = 'bar'; var_export( array_map(fn($v) => $v === $needle ? $newValue : $v, $array) );

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
162.02 ms | 1734 KiB | 10 Q