I'm pretty new to PHP and programming so I'm having troubles with this thing.
The purpose of the whole situation is to read a column from tab delimited file (already did that), get all different items in it, count them individually and put them in table with
Column1[item value - label], Column2[count].
I have the whole column in 1 dimension array. Now, I want to list all the items there and their counts beside. The problem is, I could have more than 10 different items, even more, so I can't do it manually (name 10 variables and count each) like this:
$arr = array("complete","fail","complete","exit","fail","fail","complete");
function isComplete($value){
return ($value == "complete") ? true : false;
}
$complete = array_filter($array, 'isComplete');
<tr>
<td>Complete</td>
<td><?php echo count($complete)?></td>
</tr>
-- > Complete = 3
I want to avoid manually creating every function for each value because values can differ from file to file.
The number of items in $array can go up to 20+k so I need all automated. Can someone help me with this?