3v4l.org

run code in 300+ PHP versions simultaneously
<?php function filter($array, $like, $kol) { $filtered = array_filter($array, function ($item) use ($kol, $like) { if (array_key_exists($kol, $item)) { return $item[$kol] === $like; } return false; }); return array_values($filtered); } $array = [ ["a" => "test"], ["b" => "test2"], ["c" => "test"] ]; print_r(filter($array, "test", "b")); print_r(filter($array, "test2", "b"));

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
210.1 ms | 2169 KiB | 15 Q