Re: explode a string

From: Date: Tue, 19 Apr 2005 02:29:31 +0000
Subject: Re: explode a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-213299@lists.php.net to get a copy of this message
On Mon, April 18, 2005 4:34 am, Sebastian said: > $string = '4:gaming,5:hardware,3:software,8:security'; $idcats = explode(',', $string); while (list(, $idcat) = each($idcats)){ list($id, $cat) = explode(':', $idcat); echo "\$id = $id<br />\n"; echo "\$cat = $cat<br />\n"; } > 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. 200 bytes is chump-change. It really doesn't matter how you do this, within reason. -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#213299) next »