MemphiS Posted June 5, 2007 Share Posted June 5, 2007 Example of what im kinda looking for: $array1 = array("1","2","1"); $get = count(in_array("1", $array1)); print("$get"); problem is its only returning 1 and there is clearly two "1"'s in the array anyone know how i can solve this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/54215-solved-counting-values-in-array/ Share on other sites More sharing options...
dough boy Posted June 5, 2007 Share Posted June 5, 2007 http://us.php.net/manual/en/function.array-count-values.php Quote Link to comment https://forums.phpfreaks.com/topic/54215-solved-counting-values-in-array/#findComment-268045 Share on other sites More sharing options...
MemphiS Posted June 5, 2007 Author Share Posted June 5, 2007 Thanks dough boy.. I did have a look at array_count_values but i couldnt work a way of specifying a number for it to count the value of. It only prints Array unless to print out the whole array with print_r(); which wont get the the value i wish to get. Quote Link to comment https://forums.phpfreaks.com/topic/54215-solved-counting-values-in-array/#findComment-268055 Share on other sites More sharing options...
dough boy Posted June 5, 2007 Share Posted June 5, 2007 $array1 = array("1","2","1"); $array = array_count_values($array1); echo $array[1]; // Change the 1 to whatever value you want to search for Quote Link to comment https://forums.phpfreaks.com/topic/54215-solved-counting-values-in-array/#findComment-268057 Share on other sites More sharing options...
MemphiS Posted June 5, 2007 Author Share Posted June 5, 2007 haha Thanks dough boy exactly what i was looking for Quote Link to comment https://forums.phpfreaks.com/topic/54215-solved-counting-values-in-array/#findComment-268061 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.