Re: loop through string

From: Date: Sun, 05 Jan 2003 21:10:43 +0000
Subject: Re: loop through string
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-17656@lists.php.net to get a copy of this message
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 > >

« previous php.windows (#17656) next »