CBR Posted July 18, 2007 Share Posted July 18, 2007 I have an array that has 1-100 values depending on the amount of results that are selected in a multiple form box which then created an array. I am able to display each array by echoing $array[0]-[whatever]. What I have done is then counted the array for the number of results using the following code. $tcount = count($toBox3); echo "$tcount"; Simple enough there but now I am stumped. I need for each array, run an exec command but I need it to stop at the end of the last array. It need to be dynamically done so if they select 10 results, or 100 results it builds the code needed and executes that number of time and also counts 1-whatever. So is there a way of doing this? Hope this makes sense. I will include an example of what I am attempting but with an echo statement. if ( $toBox[0] != "" ) { echo "$array[0]<br>"; } elseif ( $array[1] != "" ) { echo "$array[1]<br>"; } elseif ( $array[2] != "" ) { echo "$array[2]<br>"; } Thanks in advance for any help. Quote Link to comment Share on other sites More sharing options...
Wildbug Posted July 18, 2007 Share Posted July 18, 2007 If you just need to loop through an array, why not just use a foreach() loop? <?php foreach ($toBox as $value) if ($value != "") echo $value,"<br />"; ?> I don't understand the necessity of using exec(). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.