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 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 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. 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 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 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
Archived
This topic is now archived and is closed to further replies.