Link to home
Start Free TrialLog in
Avatar of Pedro Chagas
Pedro ChagasFlag for Portugal

asked on

Check how many times specific value in array PHP

Hi E's,
I have this code to check how many times specific value appears in php array:
$number = count(array_filter($arr_geral,function($a) {return $a=="some text example";}));   

Open in new window

That code work if I put the text inside, but don't work if I put a varible:
$text = "some text example";
$number = count(array_filter($arr_geral,function($a) {return $a==$text;})); 

Open in new window

What changes I have to do, for the above code work with a variable?
The best regards,
JC
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial