I would like to transform the code below in a function
function filter($row){return ($row['id_menu'] == 10);}
$matches = array_filter($array_mostrar_privilegios, "filter");
foreach ($matches as $element)
{
echo $element['consultar'];
}
like
function filter($row, $num)
{
return ($row['id_menu'] == $num);
}
function find($my_array, $num)
{
$matches = array_filter($my_array, "filter($row, $num)");
foreach ($matches as $element)
{
return $element['consultar'];
}
}
but i don't how to make it work
filterdoesn't callfind, andfinddoesn't callfilter. I don't understand what you're trying to achieve.array_filteris a callback. He wants to callfilterwith an extra parameter.