Posts tagged array
PHP array_keys_exist function
Jan 26th
PHP array_keys_exist function
sample:
/* test */
$result = array_keys_exist (array('key1', 'key2'), $_GET);
/**
* result
* will be true if key1 and key2 are exist in $_GET
*/
Code:
/**
* Validates the given key(s) if exist in array
* @author Fatih Piristine <v-fpiris@teknober.com>
* @param array $needle
* @param array $haystack
* @return boolean
*/
function tws_array_keys_exist(array $needles, array $haystack) {
foreach ($needles as $needle) {
if (!isset($haystack[$needle])) {
return false;
}
}
return true;
}
note: you can replace isset with array_key_exists function if you need to check the keys those have null values.
PHP GenericCollection using ArrayObject
Jan 26th
PHP GenericCollection using ArrayObject. Original Code can be found here:
just made little modification on it for own needs


LinkedIn
Twitter
Skype