note 92355 deleted from function.array-key-exists by crell

From: Date: Wed, 29 Jun 2022 20:39:07 +0000
Subject: note 92355 deleted from function.array-key-exists by crell
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-218744@lists.php.net to get a copy of this message
Note Submitter: tom at edgedesigns dot org ---- The multi_array_key_exists() function posted by alishahnovin at hotmail dot com [which has since been removed] does not always return the expected result. This modified version does. <?php /** * multi_array_key_exists function. * * @param mixed $needle The key you want to check for * @param mixed $haystack The array you want to search * @return bool */ function multi_array_key_exists( $needle, $haystack ) { foreach ( $haystack as $key => $value ) : if ( $needle == $key ) return true; if ( is_array( $value ) ) : if ( multi_array_key_exists( $needle, $value ) == true ) return true; else continue; endif; endforeach; return false; } ?>

« previous php.notes (#218744) next »