hello.
let's say i have an array with n elements and i want to create a string
with the elements separated with a comma ",".
if the array is even there's no problem, if is odd there's an extra comma at the end.
what should i do to make this work with any separator?
thanks.
need advice on this problem
Moderator: General Moderators
-
mcog_esteban
- Forum Contributor
- Posts: 127
- Joined: Tue Dec 30, 2003 3:28 pm
if I understand what you're asking, this might be a way to do it
Code: Select all
$f=0;
for($i=0;$i<n;$i++){
if($f==1){$str.=", $arrayїi]";}
else { $str.=" $arrayїi]"; $f=1;}
}-
mcog_esteban
- Forum Contributor
- Posts: 127
- Joined: Tue Dec 30, 2003 3:28 pm