Posted by phpCodeHead on 12/28/06 19:17
Hi all,
I am looking for a good way to know when I am at the end of a
comma-separated list of array values.
My code is simple (as well as I'm sure is the solution I'm looking for;
and YES I've search the php manual!! Arrggghh! )
Anyway the code goes like this:
...
<td><select name="pref_cities[]" multiple size="6">
<option>Nagpur</option>
<option>Mumbai</option>
<option>Bangalore</option>
<option>Chennai</option>
<option>Kolkatta</option>
</select></td>
...
<?php
$cities = $_POST['pref_cities'];
foreach ($cities as $city) {
echo $city . ", ";
}
?>
I want to know when I'm at the last element in $cities[] so that I can
output a period (.) instead of a comma (,).
Thanx all! Have a HAPPY NEW YEAR!!
Gene
Navigation:
[Reply to this message]
|