note 90405 deleted from function.array-unique by cmb
| From: | cmb@php.net | Date: | Mon, 12 Nov 2018 14:47:10 +0000 |
| Subject: | note 90405 deleted from function.array-unique by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-209681@lists.php.net to get a copy of this message | ||
Note Submitter: Ultimater at gmail dot com
----
Let's say you have
<?php
$v=array("blue","blue","blue","blue");
if($v[0]==$v[1] && $v[1]==$v[2] && $v[2]==$v[3])
echo "Y"; else echo "N";//Y
?>
It works but the if-statement gets a bit messy if the number of array elements gets massive.
I find it is easier to use array_unique like so:
<?php
$v=array("blue","blue","blue","blue");
echo sizeof(array_unique($v))==1?"Y":"N";//Y
?>