You are here: Re: Trying to extract KEYS out of associative array « All PHP « IT news, forums, messages
Re: Trying to extract KEYS out of associative array

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация