PDA

View Full Version : arrays question


gusblake
10-19-2006, 08:17 PM
ok so i have an array like this:

$image[0]="flowers";
$image[1]="fruit";
$image[2]="flowers";
$image[3]="flowers";
$image[4]="people";
$image[5]="people";

each value refers to the gallery to which the $image belongs, but if i just want to know how many DIFFERENT galleries there are (ie how many different values can be found in $image[] array), what would i do?

Masterslave
10-19-2006, 08:20 PM
Do you mean this?

echo count($image);
This counts the array.

CFMaBiSmAd
10-19-2006, 08:42 PM
Use array_count_value(...), then use count(...) to get the a count of unique elements -
echo count(array_count_values($image));