Reply to Re: Trying to extract KEYS out of associative array

Your name:

Reply:


Posted by ZeldorBlat on 04/17/07 20:04

On Apr 17, 12:11 am, "Me :)" <n...@this.time> wrote:
> Okay...
>
> I have setup an associative array (thru an HTML checkbox form).
> All the keys are text, all the values are 1 or null (checked or not).
>
> I need a way to dump all the KEYS of this array into a single variable.
>
> Example:
>
> $airports = array
> (
> "LGW" => "",
> "LHR" => "1",
> "STN" => "",
> "YYZ" => "1",
> "MIA" => ""
> );
>
> How do I defing $good as "LHR YYZ" ?
> (used a space as a delimiter, but it can be a comma or /, etc.)
>
> I did a bunch of dogpile searching... still haven't been able to figure
> it out. I DID find a function that worked, but it only returned the
> FIRST instance of a "1". Then it stopped. I need to traverse ALL of
> the array.
>
> Thanks!
> Mark :)

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);

[Back to original 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

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