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" <[EMAIL PROTECTED]>
To: "php-windows" <[EMAIL PROTECTED]>
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

Reply via email to