php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #64655
Patch array_diff_uassoc_jeoe12 revision 2013-04-17 09:58 UTC by jeoe12 at gmail dot com

Patch array_diff_uassoc_jeoe12 for PHP options/info functions Bug #64655

Patch version 2013-04-17 09:58 UTC

Return to Bug #64655 | Download this patch
Patch Revisions:

Developer: jeoe12@gmail.com

function php_compat_array_diff_uassoc()

{

    $args = func_get_args();
    if (count($args) < 3) {
        user_error('Wrong parameter count for array_diff_uassoc()', E_USER_WARNING);
        return;
    }
    $compare_func = array_pop($args);
    if (!is_callable($compare_func)) {
        if (is_array($compare_func)) {
            $compare_func = $compare_func[0] . '::' . $compare_func[1];
        }
        user_error('array_diff_uassoc() Not a valid callback ' .


            $compare_func, E_USER_WARNING);

        return;

    }

    $array_count = count($args);
    for ($i = 0; $i !== $array_count; $i++) {
        if (!is_array($args[$i])) {
            user_error('array_diff_uassoc() Argument #' .
                ($i + 1) . ' is not an array', E_USER_WARNING);
            return;
        }
    }
    $result = array();
    foreach ($args[0] as $k => $v) {
        for ($i = 1; $i < $array_count; $i++) {
            foreach ($args[$i] as $kk => $vv) {
                if ($v == $vv) {
                    $compare = call_user_func_array($compare_func, array($k, $kk));
                    if ($compare == 0) {
                        continue 3;
                    }
                }
            }

        }

        $result[$k] = $v;
    }
    return $result;
}
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 08:01:29 2024 UTC