Mailinglisten-Archive |
Hallo Maik, <?php function search_key($ARR, $key) { foreach($ARR as $ky => $val) { if (is_array($val)) { $res = search_key($val, $key); if ($res) { return $res; } } else { if ($ky === $key) { return array($ky => $val); } } } return false; } $TST = array( 1=>4711, 2=>array( 'r'=>'eins', 's'=>'zwei', 't'=>'drei' ), 3=>'', 4=>0, 5=>array( 'u'=>'Anna', 'v'=>array( 'x'=>123.45, 'y'=>'Berlin', 'z'=>67.89 ), 'w'=>'Claus' ), 6=>'foo' ); print_r($TST); print_r(search_key($TST, 'x')); ?> sollte alles finden was Du suchst, falls nicht - melde Dich einfach ... m. b. G. Norbert ------------------ mobil 0177-1741686 ------------------ e.o.m.
php::bar PHP Wiki - Listenarchive