Jump to content

For loop


MySQL_Narb

Recommended Posts

I can't believe I'm resorting to asking this question. I think part of my brain is still on vacation...

 

$id_list = '';
$x = 0;
for($i = 0; $i < $num; $i++){
            $id_list .= (($x+1) == $num) ? $ids[$x] : $ids[$x].',';
            $x++;
}

 

Wasn't it possible to do:

 

$id_list = '';;
for($i = 0; $i < $num; $i++){
            $id_list .= (($i+1) == $num) ? $ids[$i] : $ids[$i].',';
}

Link to comment
https://forums.phpfreaks.com/topic/266696-for-loop/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.