Gaia Posted May 3, 2006 Share Posted May 3, 2006 Hi,I have a form that is submitting multiple checkboxes, which when submitted turns into an array.So my $_POST['option'] turns into a foreach.[code]<?php$options = $_POST['option'];foreach ( $options AS $foo ) { $new_options .= 'Something: '.$foo.' ';}?>[/code]The probem is when i submit it to a database the word Array gets stuck to the first option. so say the $options resulted in 3 check boxes being marked, option1, option2, and option3.The output would be...ArraySometing: option1 Something: option2 Something: option3How do i fix that?Thanks. Link to comment https://forums.phpfreaks.com/topic/9017-array-problem/ Share on other sites More sharing options...
judeddokoinu Posted May 3, 2006 Share Posted May 3, 2006 $options is an array?Do something like:[code]<?php// do a loop on this, most likely...$options[0] = $_POST['option1'];$options[1] = $_POST['option2'];// get the values and store as a string.foreach ( $options AS $key=>$value ){ $new_options .= 'Something: '.$value.' ';}?>[/code] Link to comment https://forums.phpfreaks.com/topic/9017-array-problem/#findComment-33157 Share on other sites More sharing options...
KrisNz Posted May 4, 2006 Share Posted May 4, 2006 [code]foreach($options as $array){ foreach($array as $value) { echo $value; }} [/code] Link to comment https://forums.phpfreaks.com/topic/9017-array-problem/#findComment-33173 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.