OK, I want to count the number of unique elements in
an array, then print the total.  However, both methods
I've tried return "1"; the man pages explain that  the
count() function will return 1 if the var is set but
not an array. But if you look at the 2nd method esp.,
I've set an if-else !is_set() alert which doesn't
appear... Either way, it's a 1.  Help!

Method 1:

<?

$count =
array_unique(mysql_fetch_array($mysql_result));

$total = count($count);

print($total);

?>

Method 2:

<?

$array = mysql_fetch_array($mysql_result);

$newarray = array_values($array);

if (!is_array($newarray)) {
print("Not an array");

} else {

$count = array_unique($newarray);

foreach($count as $key => $value)  {
$count[$key] = $value++; 
}

print($value);


} 
?>

__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to