note 67911 deleted from function.array-key-exists by felipe

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
Note Submitter: marzetti.marco at gmail.com 

----

Returns the keys in $arr matching $pattern in a regex

<?php

function regex_array_keys ( &$arr, $pattern ) {
	$results[] = false;
	if( !is_array( $arr ) )
		return false;
	
	while( !is_null( $key = key( $arr ) ) ) {
		
		if( preg_match( $pattern, $key ) )
			$results[] = $key;
		next($arr);
	}
	reset( $arr );
	

	return $results;
}

?>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.