cleary1981 Posted December 15, 2008 Share Posted December 15, 2008 hi, I have a script that passes a list like this $$8$$7$$88$$12$$1$$19$$ I am using explode to get the values from this list. The problem I am having is I want to create a for loop to process these values but he length of the list can vary. Is there anyway of working out how many times the loop should run? $quotelist = $_REQUEST['quotelist']; $p = explode("$$", $quotelist); for($i=1;$i<?????;$i = $i++){ //(process info) } Link to comment https://forums.phpfreaks.com/topic/137023-setting-up-a-loop-from-explode-result/ Share on other sites More sharing options...
PravinS Posted December 15, 2008 Share Posted December 15, 2008 Use: $quotelist = $_REQUEST['quotelist']; $p = explode("$$", $quotelist); for($i=1;$i<count($p);$i = $i++){ //(process info) } Link to comment https://forums.phpfreaks.com/topic/137023-setting-up-a-loop-from-explode-result/#findComment-715648 Share on other sites More sharing options...
Mark Baker Posted December 15, 2008 Share Posted December 15, 2008 You don't even need to know how many times it runs if you use foreach: $quotelist = $_REQUEST['quotelist']; $p = explode("$$", $quotelist); foreach($p as $value){ //(process info) } Link to comment https://forums.phpfreaks.com/topic/137023-setting-up-a-loop-from-explode-result/#findComment-715661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.