|  | Posted by Steve on 04/17/07 20:53 
| How did you get the array above?  If the box isn't checked the value| shouldn't be set at all (in $_GET or $_POST).  If that were the case
 | and your array looked like this:
 |
 | $airports = array("LGW" => "", "LHR" => "1", "YYZ" => "1");
 |
 | Then it's really easy:
 |
 | implode(' ', array_keys($airports);
 
 
 follow directions!!!
 
 that would print out the keys regardless of the values, i.e. LGW would print
 when it shouldn't.
 
 how did he get the array above? probably like a good boi, he doesn't just
 grab shit out of $_POST...he'd define his inputs thusly:
 
 $airports = array(
 'LGW' => ''   ,
 'LHR' => ''   ,
 'STN' => ''   ,
 'YYZ' => ''   ,
 'MIA' => ''
 );
 
 he'd then be efficient:
 
 function setValues($value, $key, &$airports)
 {
 if (!in_array($key, array_keys($airports)){ continue; }
 $airports[$key] = $value;
 }
 array_walk($_POST, 'setValues', &$airports);
 
 which would now give you the array you are questioning. i'd imagine that he
 (and you) would only want to present/read the pertainent code...which is
 what he supplied.
 
 either way, you solution doesn't work. sorry.
  Navigation: [Reply to this message] |