php - Multidimensional array with additional boolean -
so still grasp of php arrays , proper way of doing them. have product has set of shared options options specific model. right have this
$divers = array( 'models' => array("launch 9.5","launch 12.5","launch 15.5", "launch 18.5"), 'lengths' => array(47.5, 47, 46.5, 46, 45.5, 45, 44.5, 44, 43.5, 43, 42.5, 42), );
so each model has same lengths need add boolean (true or false) model well. 9.5 true 12.5 false (basically have option in 9.5 dont in 12.5). how this? there better way set array? chose way can foreach loops spit out form elements.
you can use array values have array keys instead, add boolean value.
$divers = array( 'models' => array("launch 9.5" => true,"launch 12.5" => false,"launch 15.5", "launch 18.5"), 'lengths' => array(47.5, 47, 46.5, 46, 45.5, 45, 44.5, 44, 43.5, 43, 42.5, 42), ); foreach($divers['models'] $model) { if($model === true) { // stuff } }
Comments
Post a Comment