look under the php.net manual here:
http://us2.php.net/array_search
look down in comments by people how to search through n-dimension arrays. Note that "get something out" like you said is a bit vague.
try this function I developed, should b e what you need:
<?php
function array_keys_multi($value, $array){
#needle, haystack
/**********************
DEVELOPED 2003-10-08
This function has been needed for some time. Takes a value, and finds all instances of it in an array, and returns they keys as a 2 dimensional array. First dimension is the instance (1-based), second dimension contains the keys in order of depth (1-based).
So if your array was:
$teams[division][conference][7]='Packers'; //-- first instance
$teams[division][conference][8]='Steelers';
$teams[division][conference][9]='Titans';
$teams[division][conference][10]='Bears';
$teams[favorites][1]='Packers'; //-- second instance
$teams[myfavorite]='Packers'; //-- third instance
..and you called..
$set=array_keys_multi('Packers', $teams);
.. then $set would look like this:
#1st instance
$set[1][1]=division;
$set[1][2]=conference;
$set[1][3]=7;
#2nd instance
$set[2][1]=favorites;
$set[2][2]=1;
#3rd instance
$set[3][1]=myfavorite;
If I know there should only be one instance of a value in the array, I know all the keys of that instance by looking at $set[1]; For any $set[n], I know by its size how 'deep' the instance is in the array.
****** warning: "equal" can be dicey *****
$val1=0;
$val2='0';
if($val1===$val2){
echo 'here';
}
//what is my definition of "equal"
# 0 and blank are not equal
# 1 and '1' ARE equal
-- this should be built in or an empty would find values of zero, etc.
-- also, there should be a flag for case sensitivity
**********************/
if(isset($value)){
if(is_array($array)){
//work performed here
$i=1;
foreach($array as $n=>$v){
$level[1]=$n;
if(is_array($v)){
//2nd level
foreach($v as $o=>$w){
$level[2]=$o;
if(is_array($w)){
//3rd level
foreach($w as $p=>$q){
$level[3]=$p;
if(is_array($q)){
//4th level
foreach($q as $a=>$b){
$level[4]=$a;
if(is_array($b)){
//5th level
#not developed
#exit('function should be made recursive to go deeper');
}else{
if("$b"=="$value"){
$return[$i][1]=$level[1];
$return[$i][2]=$level[2];
$return[$i][3]=$level[3];
$return[$i][4]=$level[4];
$i++;
}
}
}
}else{
if("$q"=="$value"){
$return[$i][1]=$level[1];
$return[$i][2]=$level[2];
$return[$i][3]=$level[3];
$i++;
}
}
}
}else{
if("$w"=="$value"){
$return[$i][1]=$level[1];
$return[$i][2]=$level[2];
$i++;
}
}
}
}else{
if("$v"=="$value"){
$return[$i][1]=$level[1];
$i++;
}
}
}
}
}
return $return;
}
?>