array_search in 2-D array

From: Date: Thu, 27 Sep 2001 11:34:05 +0000
Subject: array_search in 2-D array
Groups: php.general 
Request: Send a blank email to php-general+get-68983@lists.php.net to get a copy of this message
I have a 2D array wherein each row is an associative array (which has keys that are column names of a certain MySQL table) the array name is "sess_arrayPhotos". I need to match PhotoId (2nd dimension key) for every row (numeric index) of the 2D array. I tried-- $keyPos=array_search($searchedforId,$sess_arrayPhotos); --but that didn't work. Right now, I am achieving it by: $sess_arrind=0; while(($sess_arrayPhotos[$sess_arrind]["PhotoId"] <> $photo) && ($sess_arrind < sizeof($sess_arrayPhotos))) { next($sess_arrayPhotos); $sess_arrind=$sess_arrind+1; } $keyPos=$sess_arrind; I would like to know if there is a way of doing this using array_search(). -in anticipation -Naintara

« previous php.general (#68983) next »