NathanLedet Posted June 30, 2008 Share Posted June 30, 2008 Hi, I have a form with check boxes. When the form is submitted, i use the following code to retrieve the data: $files = $_POST['files']; foreach ($files as $f => $value){ echo "$f <br />"; so everything that was checked will display as it should, but now I need to display that information in more than one location...and to me, it doesn't make sense to use a foreach statement every time I want to display that information... is it possible to use that foreach statement one time, and then store the results in an array that I can just plop anywhere I need? thanks!! Link to comment https://forums.phpfreaks.com/topic/112521-solved-storing-foreach-results-in-an-array/ Share on other sites More sharing options...
trq Posted June 30, 2008 Share Posted June 30, 2008 is it possible to use that foreach statement one time, and then store the results in an array that I can just plop anywhere I need? If you used another array you would still need to iterate through it again to display its contents. Maybe you want to store the results in a string? $files = $_POST['files']; foreach ($files as $f => $value) { $str .= $f . "<br />"; } echo $str; Link to comment https://forums.phpfreaks.com/topic/112521-solved-storing-foreach-results-in-an-array/#findComment-577753 Share on other sites More sharing options...
NathanLedet Posted June 30, 2008 Author Share Posted June 30, 2008 You....rock..... Link to comment https://forums.phpfreaks.com/topic/112521-solved-storing-foreach-results-in-an-array/#findComment-577764 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.