note 57092 deleted from function.array-intersect-key by googleguy

From: Date: Tue, 22 Oct 2013 14:54:07 +0000
Subject: note 57092 deleted from function.array-intersect-key by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-197214@lists.php.net to get a copy of this message
Note Submitter: Silvio Ginter ---- Based on the code posted by gaylord dot aulke at 100days.de i wrote this one. This should implement this function in all versions equal or greater than PHP 4.0 function array_intersect_key($arr1, $arr2) { $res = array(); foreach($arr1 as $key=>$value) { $push = true; for ($i = 1; $i < func_num_args(); $i++) { $actArray = func_get_arg($i); if (gettype($actArray) != 'array') return false; if (!array_key_exists($key, $actArray)) $push = false; } if ($push) $res[$key] = $arr1[$key]; } return $res; }

« previous php.notes (#197214) next »