Re: Re: PHP 4.0 Bug #6414 Updated: foreach() doesn't accept string for an argument
| From: | Cynic | Date: | Tue, 29 Aug 2000 17:00:11 +0000 |
| Subject: | Re: Re: PHP 4.0 Bug #6414 Updated: foreach() doesn't accept string for an argument | ||
| References: | 1 2 3 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-31093@lists.php.net to get a copy of this message | ||
But strings are basically arrays, right? The extent of their
arrayishness should be probably stated somewhere.
At 11:40 AM 8/29/00 -0500, Andrei Zmievski wrote the following:
--------------------------------------------------------------
>On Tue, 29 Aug 2000, James Moore wrote:
>> OK this might well be true I didnt test it.. But the manual does state
>> foreach needs array inputs not string inputs, so it is not suprising that
>> PHP complains when you pass it a string, I reliase that strings/arrays can
>> be treated similarly, I suggest you convert it to an array using some loop..
>> Maybe somthing like:
>>
>> for($i=0;$i<strlen($b);$i++) {
>>
>> $b_array[] = $b[$i]; /* You might need $b_array = substr($b,$i,1); instead
>> here... */
>>
>> }
>
>$letters = preg_split("//", $word);
>
>-Andrei
>
>Politics is for the moment, an equation is for eternity.
>
> -- Albert Einstein
------end of quote------
____________________________________________________________
Cynic:
A member of a group of ancient Greek philosophers who taught
that virtue constitutes happiness and that self control is
the essential part of virtue.
cynic@mail.cz
ICQ: 2808 2505