Re: [PHP] explode a string

2005-04-20 Thread Saswat Praharaj
explode by "," $output1 = explode(",",$string); use a loop and explode array $output1 by ":" Hope this helps. Saswat On 4/18/05, Sebastian <[EMAIL PROTECTED]> wrote: > $string = '4:gaming,5:hardware,3:software,8:security'; > > what is the best way to explode then loop this string after its t

[PHP] explode a string

2005-04-20 Thread Rory Browne
Sorry jocham, for you getting this twice. I'd assume foreach is recommended because it lends to more readable code. More readable code, is generally considered better code. Personally I'd disagree and use while( list() = each() ), because it doesn't create a copy of the array in memory, especiall

Re: [PHP] explode a string

2005-04-20 Thread Jochem Maas
Richard Lynch wrote: On Tue, April 19, 2005 7:03 am, Jochem Maas said: The 'other' guy mentioned that while() is faster than foreach, is this true? Don't know ; Don't care. You should never loop through so many things in PHP that it matters in the first place :-) I read a few days ago somewhere o

Re: [PHP] explode a string

2005-04-19 Thread Richard Lynch
On Tue, April 19, 2005 7:03 am, Jochem Maas said: > The 'other' guy mentioned that while() is faster than foreach, > is this true? Don't know ; Don't care. You should never loop through so many things in PHP that it matters in the first place :-) > I read a few days ago somewhere on php.net that

Re: [PHP] explode a string

2005-04-19 Thread Jochem Maas
Petar Nedyalkov wrote: On Tuesday 19 April 2005 17:03, Jochem Maas wrote: Richard Lynch wrote: 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('

Re: [PHP] explode a string

2005-04-19 Thread Petar Nedyalkov
On Tuesday 19 April 2005 17:03, Jochem Maas wrote: > Richard Lynch wrote: > > 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) = explo

Re: [PHP] explode a string

2005-04-19 Thread Jochem Maas
Richard Lynch wrote: 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\n"; echo "\$cat = $cat\n"; } The 'othe

Re: [PHP] explode a string

2005-04-18 Thread Richard Lynch
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\n"; echo "\$cat = $cat\n"; } > what is the best way to e

Re: [PHP] explode a string

2005-04-18 Thread Petar Nedyalkov
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/fas

[PHP] explode a string

2005-04-18 Thread Sebastian
$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 mo

RE: [PHP] Explode a string

2003-11-12 Thread Wouter van Vliet
Jay Blanchard wrote: > [snip] > Considering Jay's answer for this question, do I always do things the > hard way or what?? [/snip] > > Young Grasshopper...there is more than one way to do things, > a lot of them are "right"some are just harder than others. Isn't that the diplomatic equivalent

RE: [PHP] Explode a string

2003-11-12 Thread Jay Blanchard
[snip] Considering Jay's answer for this question, do I always do things the hard way or what?? [/snip] Young Grasshopper...there is more than one way to do things, a lot of them are "right"some are just harder than others. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, vi

RE: [PHP] Explode a string

2003-11-12 Thread Chris W. Parker
Chris W. Parker <> on Wednesday, November 12, 2003 9:19 AM said: > Without knowing any other way to do this I would use a regex to skip > the first + and change second one, repeating this until the end of the > string. Considering Jay's answer for this question, do I always do things the hard

RE: [PHP] Explode a string

2003-11-12 Thread Chris W. Parker
Erin on Wednesday, November 12, 2003 9:13 AM said: > 734088+3+734132+9+734138+80+781007+1+ > > I need to place the string into a multi-array like so > > array[0][0] = 734088 > array[0][1] = 3 [snip] > Now ive tried everything i know any ideas? Yes. You need to som

RE: [PHP] Explode a string

2003-11-12 Thread Jay Blanchard
[snip] Any ideas how to do this, I have a string 734088+3+734132+9+734138+80+781007+1+ I need to place the string into a multi-array like so array[0][0] = 734088 array[0][1] = 3 etc... Now ive tried everything i know any ideas? [/snip] start with explode $arrString = explode("+", $stringYo

[PHP] Explode a string

2003-11-12 Thread Erin
Any ideas how to do this, I have a string 734088+3+734132+9+734138+80+781007+1+ I need to place the string into a multi-array like so array[0][0] = 734088 array[0][1] = 3 array[1][0] = 734132 array[1][1] = 9 array[2][0] = 734138 array[2][1] = 80 etc... Now ive tried everything i know any id