if ( count ( array_unique ( $array ) ) == 1 ) {
 // all fields have the same value
}
we could post solution to this problem for ever...
- Hannes

On Sat, 14 Aug 2004 15:24:03 +0100
[EMAIL PROTECTED] (Mike Ford) wrote:

> -----Original Message-----
> From: Brent Clements
> To: [EMAIL PROTECTED]
> 
> I wanted to see if anyone has an easier way to do this. The end result
> is this: I need to compare 7 different text strings(which are in an
> array). They should all be the same, if they are not the same, a message
> should be outputted saying they weren't.
> 
> How would one do this outside of using a huge if/then statement?
> 
> ---------------------------
> 
> Two approaches come to mind off the top of my head:
> 
>   $values = array_count_values($array);
> 
>   if (count($values)>1):
>     // there's more than one unique value in the array
>   endif;
> 
> or...
> 
>   $value = $array[0];
>   for ($i=1; $i<7; ++$i):
>     if ($array[$i]!= $value):
>       // this value doesn't match
>       break;
>     endif;
>   endfor;
> 
> Cheers!
> 
> Mike

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to