Re: explode a string
| From: | Petar Nedyalkov | Date: | Mon, 18 Apr 2005 14:07:08 +0000 |
| Subject: | Re: explode a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-213271@lists.php.net to get a copy of this message | ||
On Monday 18 April 2005 14:34, Sebastian wrote:
> $string = '4:gaming,5:hardware,3:software,8:security';
>
> what is the best way to explode then loop this string after its taken
> apart.
>
> output should be something like:
>
> $id = 4
> $cat = gaming
>
> etc..
>
> im just looking for the best/fastest way to do this. the string can grow to
> 200 or so bytes, maybe more.
>
> should i list(), while(), explode it, or should i explode it and foreach
> it? or..?
while is faster than foreach. check the iterator section in SPL for details.
>
> thanks.
--
Cyberly yours,
Petar Nedyalkov
Devoted Orbitel Fan :-)
PGP ID: 7AE45436
PGP Public Key: http://bu.orbitel.bg/pgp/bu.asc
PGP Fingerprint: 7923 8D52 B145 02E8 6F63 8BDA 2D3F 7C0B 7AE4 5436
Attachment: [application/pgp-signature]
Attachment: [application/pgp-signature]