|
Posted by Steve on 04/17/07 05:35
sorry...my bad. you need to pass $selectedAirports byref. i'm glad i ran the
code to test it...that was just top-o-the-head so i felt i should at least
give it a go for syntax and the like. change the following to:
array_walk($airports, 'filterAirports', &$selectedAirports);
and all should be well.
"Steve" <no.one@example.com> wrote in message
news:1PYUh.1033$PA6.110@newsfe04.lga...
| easier than you'd think...
|
| <?
| function filterAirports($value, $key, &$selected)
| {
| if (!$value){ return; }
| $selected[] = $key;
| }
| $airports = array(
| 'LGW' => '' ,
| 'LHR' => '1' ,
| 'STN' => '' ,
| 'YYZ' => '1' ,
| 'MIA' => ''
| );
| $selectedAirports = array();
| array_walk($airports, 'filterAirports', $selectedAirports);
| $selectedAirports = implode(' ', $selectedAirports);
| print_r($selectedAirports);
| ?>
|
| happy flying...and thanks for not yelling this time. :)
|
|
| "Me :)" <not@this.time> wrote in message
| news:6sh823164tdfvv4ccaq67rqsltts9c2ip0@4ax.com...
|| 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 :)
|
|
[Back to original message]
|