/**
* Searches an array for a specific key/value pair
*
* @param array $array The array to be searched
* @param string $key The key part of the search
* @param string $value The value part of the search
*
* @return array An array of matching elements
*/
private function search_array( $array, $key, $value ) {
$results = array();
if ( is_array( $array ) ) {
if ( isset( $array[ $key ] ) && $array[ $key ] == $value ) {
$results[] = $array;
}
foreach ( $array as $subarray ) {
$results = array_merge( $results, $this->search_array( $subarray, $key, $value ) );
}
}
return $results;
}
Searches a multidimensional/nested array for a specific key/value pair. If that pair is found it is returned.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.