Pjack125 Posted December 2, 2008 Share Posted December 2, 2008 I want to put information from check boxes into an array but the issue is not all of the check boxes are require to have information in there so i end up having something like so for the array $Department = array("value1","","value3","","","value6"); what I want to do is manipulate that array to where i have $Department = array("value1","value3","value6"); Is there any way to achieve such result I would even be willing to settle for a way to load only those values into a new array called $Selected or something. Quote Link to comment https://forums.phpfreaks.com/topic/135146-solved-cleaning-up-an-array/ Share on other sites More sharing options...
trq Posted December 2, 2008 Share Posted December 2, 2008 Only checkboxes that have been checked should be passed to your script. Can we see your form? Quote Link to comment https://forums.phpfreaks.com/topic/135146-solved-cleaning-up-an-array/#findComment-703907 Share on other sites More sharing options...
Pjack125 Posted December 2, 2008 Author Share Posted December 2, 2008 The form is located at http://www.pixelfxmedia.com/lewiz.php I am currently trying to use while (list ($key,$val) = @each ($Dept)) { echo "$val,"; } to construct my array now and can't seem no navigate trough it using array_search Quote Link to comment https://forums.phpfreaks.com/topic/135146-solved-cleaning-up-an-array/#findComment-704105 Share on other sites More sharing options...
Maq Posted December 2, 2008 Share Posted December 2, 2008 Like thorpe said, unchecked boxes should not show up. But you could do something like this. foreach($array as $key => $value) { if($value == "") { unset($array[$key]); } } $new_array = array_values($array); Quote Link to comment https://forums.phpfreaks.com/topic/135146-solved-cleaning-up-an-array/#findComment-704109 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.