How do I count how much times a number is in the 2 dimensional table ?
Code example:
array (size=3)
0 =>
array (size=7)
0 => int 19
1 => int 17
2 => int 37
3 => int 3
4 => int 17
5 => int 11
6 => int 23
1 =>
array (size=7)
0 => int 16
1 => int 30
2 => int 16
3 => int 4
4 => int 24
5 => int 14
6 => int 15
2 =>
array (size=7)
0 => int 11
1 => int 41
2 => int 30
3 => int 11
4 => int 10
5 => int 18
6 => int 36
i'm trying to find out how to search how many times each number is in the table. This is what I got :
$arrayWeeknummer = array();
echo "<table>";
for ($i = 0; $i < 3; $i++)
{
echo "<tr>";
for($j = 0; $j < 7; $j++)
{
$arrayWeeknummer[$i][$j] = rand(1,42);
echo "<td>".$arrayWeeknummer[$i][$j]."</td>";
}
echo "</tr>";
}
echo "</table>";
for($k = 0; $k < 42; $k++)
{
$aantal = 0;
$newArray[$k][0] = $k+1;
if(array_search($k+1, $arrayWeeknummer))
{
$newArray[$k][1] = $aantal++;
}
$newArray[$k][1] = $aantal;
}
Unfortunately i'm doing something wrong in my if (array_search) statement since it never get called.
array_count_values?