Re: loop through string
| From: | Gregory Lewis | Date: | Sun, 05 Jan 2003 23:50:15 +0000 |
| Subject: | Re: loop through string | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-17658@lists.php.net to get a copy of this message | ||
Excuse me, that was a thanks to Cam and Ignatius, and the loop-through-llist using the explode
function was just the ticket.
-Greg Lewis
---------- Original Message ----------------------------------
From: "Gregory Lewis" <php@interdatacentral.com>
Reply-To: <php@interdatacentral.com>
Date: Sun, 5 Jan 2003 15:30:14 -0600
>Thanks Cam and Rasmus, looks simple enough. You guys are awesome.
>
>-Greg
>
>---------- Original Message ----------------------------------
>From: "Cam Dunstan" <cam@norex.com.au>
>Date: Mon, 6 Jan 2003 08:10:43 +1100
>
>>Welcome to the list Greg,
>>
>>There are thousand ways - try converting the string to an array then looping
>>through the array with either a for() loop, a do-while or a foreach()
>>
>>
>>$my_array = explode(",", $mylist);
>>
>>foreach ($my_array as $one_element) {
>> echo $one_element."<br>";
>>}
>>
>>
>> - or -
>>
>>$my_array = explode(",", $mylist);
>>
>>$array_count = count($my_array);
>>
>>for ($j = 0; $j < $array_count; $j++) {
>>echo $my_array[$j];
>>echo "<br>\n";
>>}
>>
>>etc etc.
>>
>>Have a squizz at the manual on each() and list() functions and the while()
>>constructs also, and a very rich set of array and string functions in
>>general.
>>
>>
>>
>>----- Original Message -----
>>From: "Gregory Lewis" <php@interdatacentral.com>
>>To: "php-windows" <php-windows@lists.php.net>
>>Sent: Monday, January 06, 2003 6:18 AM
>>Subject: [PHP-WIN] loop through string
>>
>>
>>> Hi my name is Greg Lewis and I'm new to this list and to PHP. I have
>>experience with Cold Fusion, and so hopefully the transition won't be too
>>hard.
>>>
>>> My first question: How do I loop through a comma delimited list?
>>>
>>> ex: $mylist = "a,b,c,d,e,f,g";
>>>
>>> thanks for your time and patience,
>>>
>>> Greg
>>>
>>>
>>> --
>>> PHP Windows Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>>
>>--
>>PHP Windows Mailing List (http://www.php.net/)
>>To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>
>