Re: Unique Array
| From: | CC Zona | Date: | Mon, 10 Sep 2001 11:47:17 +0000 |
| Subject: | Re: Unique Array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-66727@lists.php.net to get a copy of this message | ||
In article <F135FwtuYS6VnL9wtlo0000a9f7@hotmail.com>,
mccanndee@hotmail.com (Deirdre Mc Cann) wrote:
> for ($i = 0; $i<100; $i++){
> $a[$i] = rand(0,9);
> $test=$a[$i];
> }
>
> $ra = array_unique($test);
>
> I keep getting an error saying $test is the incorrect type. Can someone
> please explain why this doesn't work.
$test is a string variable, not an array. To add elements to an array,
either use $varname[], array_push(), or array_unshift().
BTW, when an error message says that a variable is not the right type, this
is a good time to use gettype() and/or var_dump() in order to check that
the variable really has the type and value(s) what that you expect.
--
CC