php - Get name option and value with multi input checkbox -


i have form entry

<input type="checkbox" name="option[repassage]" id="options1" value="10.00"> repassage 30 mn <input type="checkbox" name="option[frigo]" id="options2" value="5.00"> frigo 30 mn 

with php options , put them in array can not right values 'titre_option' , 'prix_option' !!!

if (isset($_post['option'])) {     foreach ( $_post['option'] $key => $value ) {         $_session['option'][] = array('titre_option' => $_post['option'][$key], 'prix_option' => $_post['option'][$value]);     } }  // array (     [0] => array         (             [titre_option] => 10.00             [prix_option] =>          )      [1] => array         (             [titre_option] => 5.00             [prix_option] =>          )  )  // need array (     [0] => array         (             [titre_option] => repassage             [prix_option] => 10.00         )      [1] => array         (             [titre_option] => frigo             [prix_option] => 5.00         )  ) 

thank help...

change line

$_session['option'][] = array('titre_option' => $_post['option'][$key], 'prix_option' => $_post['option'][$value]); 

to this

$_session['option'][] = array('titre_option' => $key, 'prix_option' => $value); 

because of foreach loop, have right variables, , don't need them again array.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -