Re: Character Array
| From: | Philip Olson | Date: | Thu, 11 Jul 2002 16:19:41 +0000 |
| Subject: | Re: Character Array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-107172@lists.php.net to get a copy of this message | ||
Yeah, it behaves like that. But keep in mind
that you should use {} instead of [] for strings
as [] with strings like this is deprecated.
$str = 'abc';
print $str{0}; // a
print $str{2}; // c
The manual also talks about this use too:
http://www.php.net/manual/en/language.types.string.php
Regards,
Philip Olson
On Thu, 11 Jul 2002, Michal Dvoracek wrote:
> Hello,
>
> IMHO string is array of characters
>
> so is possible:
> $str = 'string';
> for ($i = 0; $ < count($str); $i++)
> echo $str[$i];
>
> Regards,
> Michal Dvoracek michal.dvoracek@capitol.cz
> Capitol Internet Publisher, Korunovacni 6, 170 00 Prague 7, Czech Republic
> tel.: ++420 2 3337 1117, fax: ++420 2 3337 1112
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>