MySQL_Narb Posted August 5, 2012 Share Posted August 5, 2012 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 More sharing options...
requinix Posted August 5, 2012 Share Posted August 5, 2012 Yes. Unless I'm missing something those two should behave exactly the same. Except it's probably all moot anyways. $id_list = implode(',', $ids); Link to comment https://forums.phpfreaks.com/topic/266696-for-loop/#findComment-1366915 Share on other sites More sharing options...
MySQL_Narb Posted August 5, 2012 Author Share Posted August 5, 2012 Yes. Unless I'm missing something those two should behave exactly the same. Except it's probably all moot anyways. $id_list = implode(',', $ids); <.<... Link to comment https://forums.phpfreaks.com/topic/266696-for-loop/#findComment-1366917 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.