Last change
on this file since 6082 was
3282,
checked in by plg, 16 years ago
|
change: according to topic:15067, svn:keywords property was removed
|
-
Property svn:eol-style set to
LF
|
File size:
899 bytes
|
Line | |
---|
1 | <?php |
---|
2 | // http://www.php.net/manual/en/function.array-intersect-key.php |
---|
3 | // PHP 5 >= 5.1.0RC1 |
---|
4 | function array_intersect_key() |
---|
5 | { |
---|
6 | $args = func_get_args(); |
---|
7 | if (count($args) < 2) { |
---|
8 | trigger_error('Wrong parameter count for array_intersect_key()', E_USER_WARNING); |
---|
9 | return; |
---|
10 | } |
---|
11 | |
---|
12 | // Check arrays |
---|
13 | $array_count = count($args); |
---|
14 | for ($i = 0; $i !== $array_count; $i++) { |
---|
15 | if (!is_array($args[$i])) { |
---|
16 | trigger_error('array_intersect_key() Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); |
---|
17 | return; |
---|
18 | } |
---|
19 | } |
---|
20 | |
---|
21 | // Compare entries |
---|
22 | $result = array(); |
---|
23 | foreach ($args[0] as $key1 => $value1) { |
---|
24 | for ($i = 1; $i !== $array_count; $i++) { |
---|
25 | foreach ($args[$i] as $key2 => $value2) { |
---|
26 | if ((string) $key1 === (string) $key2) { |
---|
27 | $result[$key1] = $value1; |
---|
28 | } |
---|
29 | } |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | return $result; |
---|
34 | } |
---|
35 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.