Re: Troubles from the newb again

From: Date: Sat, 10 Mar 2007 09:14:57 +0000
Subject: Re: Troubles from the newb again
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-250193@lists.php.net to get a copy of this message
Jeff Taylor wrote:
Yeah I have, but what I dont understand is that the value of $name is an object, and was accepted in the original array as the index: the original array was: $me = new Toon(xxxx,xxx,xxx,xxxx,xxx,etc,etc,etc) $him = new Toon(xxx,xxxxxx,xxxxx,etc,etc,etc,etc) .... $array=array($me,$him) Hell no,
there's a difference between: $array[$me] and array($me); The first results in: $array[$me] = null; the other results in $array[0] = $me; Note that in the 2nd one you assign $me as the first value of the array, and in the 1st one you assign $me to be the first index/key of the array (with a null value).
So this new array, I want to isolate those toons still alive:
    if alive then
    add toon to new array
Is this possible in anyway? The reason why I dont want it to put it in a value: foreach ($newarray as $name) {
    if (in_array($name,$characters))
    {
     $newarray[$name] = 1;
    }
    else
    {
     $newarray[$name] = 2;
    }
} Sorry for the spam everyone Then use $name as being an actual NAME (aka "string") instead of the entire toon you are talking about (aka "object").
- tul

« previous php.general (#250193) next »