Re: ARRAY QUESTION
| From: | Kevin Stone | Date: | Thu, 24 Jul 2003 20:18:57 +0000 |
| Subject: | Re: ARRAY QUESTION | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-156736@lists.php.net to get a copy of this message | ||
"Dale Hersh" <dalehersh@hotmail.com> wrote in message
news:20030724193903.81534.qmail@pb1.pair.com...
> I have a question regarding the count function. Here goes:
>
> Lets pretend I have this array called myStuff. If I add two elements to
> myStuff and call the count function, I will get a result of 2. My question
> is how do I re-initialize the array after adding elements so when I call
the
> count function on the array, I get a result of 0.
>
> Thanks,
> Dale
I assume you want to KEEP the other values in the array? If not then you
can just unset($myStuff).
If you do want to keep the array intact then I suppose you could store the
count in a variable $counta, add more elements to the array (or not), take
the count again and store it in a new variable $countb, then subtract the
values $count = abs($counta - $countb);
abs() converts to the absolute value if the result is negative.
- Kevin