I have an array of tags taken from a MySQL database. Obviously, these tags are strings and are stored in an array, with one element in the array storing each tag. TO build my tag cloud, I want to be able to count the occurrences of each tag to find the most common tag.
For example, if I have the table below…
tag1 tag1 hi bye gnu tux tag1 tux tux tag1 ... etc
… the most commonly occurring tag is “tag1” what I want to do is count how many times that tag occurs in the array. Max() doesn’t help here due to it only liking numerical values.
use array_count_values
http://php.net/manual/en/function.array-count-values.php
if you do not want the case-sensitive version use :