<?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"));
preferences:
25.22 ms | 406 KiB | 5 Q