cvs: pear /PHP_Compat/Compat/Function array_uintersect.php array_uintersect_assoc.php array_uintersect_uassoc.php
| From: | Aidan Lister | Date: | Fri, 27 Aug 2004 12:19:21 +0000 |
| Subject: | cvs: pear /PHP_Compat/Compat/Function array_uintersect.php array_uintersect_assoc.php array_uintersect_uassoc.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-23361@lists.php.net to get a copy of this message | ||
aidan Fri Aug 27 08:19:21 2004 EDT
Modified files:
/pear/PHP_Compat/Compat/Function array_uintersect.php
array_uintersect_assoc.php
array_uintersect_uassoc.php
Log:
Initial attempts, not working
http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/array_uintersect.php?r1=1.1&r2=1.2&ty=u Index: pear/PHP_Compat/Compat/Function/array_uintersect.php diff -u pear/PHP_Compat/Compat/Function/array_uintersect.php:1.1 pear/PHP_Compat/Compat/Function/array_uintersect.php:1.2 --- pear/PHP_Compat/Compat/Function/array_uintersect.php:1.1 Sun Aug 22 08:15:01 2004 +++ pear/PHP_Compat/Compat/Function/array_uintersect.php Fri Aug 27 08:19:20 2004 @@ -12,10 +12,11 @@ // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | +// | Authors: Tom Buskens <ortega@php.net> | +// | Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: array_uintersect.php,v 1.1 2004/08/22 12:15:01 aidan Exp $ +// $Id: array_uintersect.php,v 1.2 2004/08/27 12:19:20 aidan Exp $ /** @@ -24,8 +25,9 @@ * @category PHP * @package PHP_Compat * @link http://php.net/array_uintersect + * @author Tom Buskens <ortega@php.net> * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @since PHP 5 * @require PHP 4.0.1 (trigger_error) */ @@ -33,7 +35,58 @@ { function array_uintersect() { + // Get arguments + $args = func_get_args(); + if (count($args) < 3) { + trigger_error('wrong parameter count for array_uintersect()', E_USER_WARNING); + return; + } + + // Get callback functions + $user_func_item = array_pop($args); + + if (is_array($user_func_item) && count($user_func_item) === 2) { + $user_func_item = current($user_func_item) . '::' . current($user_func_item); + } + if (!is_callable($user_func_item)) { + trigger_error('array_uintersect() Not a valid callback ' . $user_func_item, E_USER_WARNING); + return; + } + + // Check arrays + $array_count = count($args); + + for ($i = 0; $i !== $array_count; $i++) { + + if (!is_array($args[$i])) { + trigger_error('array_uintersect() [...]: Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); + return; + } + + } + + // Compare entries + $output = array(); + foreach ($args[0] as $key => $item) { + + for ($i = 1; $i !== $array_count; $i++) { + + $array = $args[$i]; + + foreach($array as $key0 => $item0) { + + if (!call_user_func($user_func_item, $item, $item0)) { + + $output[$key] = $item; + + } + + } + } + } + + return $output; } } http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php?r1=1.2&r2=1.3&ty=u Index: pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php diff -u pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php:1.2 pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php:1.3 --- pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php:1.2 Thu Aug 19 06:09:53 2004 +++ pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php Fri Aug 27 08:19:20 2004 @@ -12,10 +12,11 @@ // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | +// | Authors: Tom Buskens <ortega@php.net> | +// | Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: array_uintersect_assoc.php,v 1.2 2004/08/19 10:09:53 aidan Exp $ +// $Id: array_uintersect_assoc.php,v 1.3 2004/08/27 12:19:20 aidan Exp $ /** @@ -24,8 +25,9 @@ * @category PHP * @package PHP_Compat * @link http://php.net/array_uintersect_assoc + * @author Tom Buskens <ortega@php.net> * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @since PHP 5 * @require PHP 4.0.1 (trigger_error) */ @@ -33,7 +35,55 @@ { function array_uintersect_assoc() { + // Get arguments + $args = func_get_args(); + if (count($args) < 3) { + trigger_error('wrong parameter count for array_uintersect_assoc()', E_USER_WARNING); + return; + } + + // Get callback function + $user_func = array_pop($args); + + if (is_array($user_func) && count($user_func) === 2) { + $user_func = current($user_func) . '::' . current($user_func); + } + if (!is_callable($user_func)) { + trigger_error('array_uintersect_assoc() Not a valid callback ' . $user_func, E_USER_WARNING); + return; + } + + // Check arrays + $array_count = count($args); + + for ($i = 0; $i !== $array_count; $i++) { + + if (!is_array($args[$i])) { + trigger_error('array_uintersect_assoc() [...]: Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); + return; + } + + } + + // Compare entries + $output = array(); + foreach ($args[0] as $key => $item) { + + for ($i = 1; $i !== $array_count; $i++) { + + if (array_key_exists($key, $args[$i])) { + $compare = call_user_func($user_func, $item, $args[$i][$key]); + if ($compare === 0) { + $output[$key] = $item; + } + } + + } + + } + + return $output; } } http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php?r1=1.2&r2=1.3&ty=u Index: pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php diff -u pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php:1.2 pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php:1.3 --- pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php:1.2 Thu Aug 19 06:09:53 2004 +++ pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php Fri Aug 27 08:19:20 2004 @@ -12,10 +12,11 @@ // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | +// | Authors: Tom Buskens <ortega@php.net> | +// | Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: array_uintersect_uassoc.php,v 1.2 2004/08/19 10:09:53 aidan Exp $ +// $Id: array_uintersect_uassoc.php,v 1.3 2004/08/27 12:19:20 aidan Exp $ /** @@ -24,8 +25,9 @@ * @category PHP * @package PHP_Compat * @link http://php.net/array_uintersect_uassoc + * @author Tom Buskens <ortega@php.net> * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @since PHP 5 * @require PHP 4.0.1 (trigger_error) */ @@ -33,7 +35,67 @@ { function array_uintersect_uassoc() { + // Get arguments + $args = func_get_args(); + if (count($args) < 3) { + trigger_error('wrong parameter count for array_uintersect_uassoc()', E_USER_WARNING); + return; + } + + // Get callback functions + $user_func_item = array_pop($args); + $user_func_key = array_pop($args); + + if (is_array($user_func_item) && count($user_func_item) === 2) { + $user_func_item = current($user_func_item) . '::' . current($user_func_item); + } + if (!is_callable($user_func_item)) { + trigger_error('array_uintersect_uassoc() Not a valid callback ' . $user_func_item, E_USER_WARNING); + return; + } + if (is_array($user_func_key) && count($user_func_key) === 2) { + $user_func_key = current($user_func_key) . '::' . current($user_func_key); + } + if (!is_callable($user_func_key)) { + trigger_error('array_uintersect_uassoc() Not a valid callback ' . $user_func_key, E_USER_WARNING); + return; + } + + // Check arrays + $array_count = count($args); + + for ($i = 0; $i !== $array_count; $i++) { + + if (!is_array($args[$i])) { + trigger_error('array_uintersect_uassoc() [...]: Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); + return; + } + + } + + // Compare entries + $output = array(); + foreach ($args[0] as $key => $item) { + + for ($i = 1; $i !== $array_count; $i++) { + + $array = $args[$i]; + + foreach($array as $key0 => $item0) { + + if (!call_user_func($user_func_key, $key, $key0) && + !call_user_func($user_func_item, $item, $item0)) { + + $output[$key] = $item; + + } + + } + } + } + + return $output; } }
http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/array_uintersect.php?r1=1.1&r2=1.2&ty=u Index: pear/PHP_Compat/Compat/Function/array_uintersect.php diff -u pear/PHP_Compat/Compat/Function/array_uintersect.php:1.1 pear/PHP_Compat/Compat/Function/array_uintersect.php:1.2 --- pear/PHP_Compat/Compat/Function/array_uintersect.php:1.1 Sun Aug 22 08:15:01 2004 +++ pear/PHP_Compat/Compat/Function/array_uintersect.php Fri Aug 27 08:19:20 2004 @@ -12,10 +12,11 @@ // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | +// | Authors: Tom Buskens <ortega@php.net> | +// | Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: array_uintersect.php,v 1.1 2004/08/22 12:15:01 aidan Exp $ +// $Id: array_uintersect.php,v 1.2 2004/08/27 12:19:20 aidan Exp $ /** @@ -24,8 +25,9 @@ * @category PHP * @package PHP_Compat * @link http://php.net/array_uintersect + * @author Tom Buskens <ortega@php.net> * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * @since PHP 5 * @require PHP 4.0.1 (trigger_error) */ @@ -33,7 +35,58 @@ { function array_uintersect() { + // Get arguments + $args = func_get_args(); + if (count($args) < 3) { + trigger_error('wrong parameter count for array_uintersect()', E_USER_WARNING); + return; + } + + // Get callback functions + $user_func_item = array_pop($args); + + if (is_array($user_func_item) && count($user_func_item) === 2) { + $user_func_item = current($user_func_item) . '::' . current($user_func_item); + } + if (!is_callable($user_func_item)) { + trigger_error('array_uintersect() Not a valid callback ' . $user_func_item, E_USER_WARNING); + return; + } + + // Check arrays + $array_count = count($args); + + for ($i = 0; $i !== $array_count; $i++) { + + if (!is_array($args[$i])) { + trigger_error('array_uintersect() [...]: Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); + return; + } + + } + + // Compare entries + $output = array(); + foreach ($args[0] as $key => $item) { + + for ($i = 1; $i !== $array_count; $i++) { + + $array = $args[$i]; + + foreach($array as $key0 => $item0) { + + if (!call_user_func($user_func_item, $item, $item0)) { + + $output[$key] = $item; + + } + + } + } + } + + return $output; } } http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php?r1=1.2&r2=1.3&ty=u Index: pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php diff -u pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php:1.2 pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php:1.3 --- pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php:1.2 Thu Aug 19 06:09:53 2004 +++ pear/PHP_Compat/Compat/Function/array_uintersect_assoc.php Fri Aug 27 08:19:20 2004 @@ -12,10 +12,11 @@ // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | +// | Authors: Tom Buskens <ortega@php.net> | +// | Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: array_uintersect_assoc.php,v 1.2 2004/08/19 10:09:53 aidan Exp $ +// $Id: array_uintersect_assoc.php,v 1.3 2004/08/27 12:19:20 aidan Exp $ /** @@ -24,8 +25,9 @@ * @category PHP * @package PHP_Compat * @link http://php.net/array_uintersect_assoc + * @author Tom Buskens <ortega@php.net> * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @since PHP 5 * @require PHP 4.0.1 (trigger_error) */ @@ -33,7 +35,55 @@ { function array_uintersect_assoc() { + // Get arguments + $args = func_get_args(); + if (count($args) < 3) { + trigger_error('wrong parameter count for array_uintersect_assoc()', E_USER_WARNING); + return; + } + + // Get callback function + $user_func = array_pop($args); + + if (is_array($user_func) && count($user_func) === 2) { + $user_func = current($user_func) . '::' . current($user_func); + } + if (!is_callable($user_func)) { + trigger_error('array_uintersect_assoc() Not a valid callback ' . $user_func, E_USER_WARNING); + return; + } + + // Check arrays + $array_count = count($args); + + for ($i = 0; $i !== $array_count; $i++) { + + if (!is_array($args[$i])) { + trigger_error('array_uintersect_assoc() [...]: Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); + return; + } + + } + + // Compare entries + $output = array(); + foreach ($args[0] as $key => $item) { + + for ($i = 1; $i !== $array_count; $i++) { + + if (array_key_exists($key, $args[$i])) { + $compare = call_user_func($user_func, $item, $args[$i][$key]); + if ($compare === 0) { + $output[$key] = $item; + } + } + + } + + } + + return $output; } } http://cvs.php.net/diff.php/pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php?r1=1.2&r2=1.3&ty=u Index: pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php diff -u pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php:1.2 pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php:1.3 --- pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php:1.2 Thu Aug 19 06:09:53 2004 +++ pear/PHP_Compat/Compat/Function/array_uintersect_uassoc.php Fri Aug 27 08:19:20 2004 @@ -12,10 +12,11 @@ // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ -// | Authors: Aidan Lister <aidan@php.net> | +// | Authors: Tom Buskens <ortega@php.net> | +// | Aidan Lister <aidan@php.net> | // +----------------------------------------------------------------------+ // -// $Id: array_uintersect_uassoc.php,v 1.2 2004/08/19 10:09:53 aidan Exp $ +// $Id: array_uintersect_uassoc.php,v 1.3 2004/08/27 12:19:20 aidan Exp $ /** @@ -24,8 +25,9 @@ * @category PHP * @package PHP_Compat * @link http://php.net/array_uintersect_uassoc + * @author Tom Buskens <ortega@php.net> * @author Aidan Lister <aidan@php.net> - * @version $Revision: 1.2 $ + * @version $Revision: 1.3 $ * @since PHP 5 * @require PHP 4.0.1 (trigger_error) */ @@ -33,7 +35,67 @@ { function array_uintersect_uassoc() { + // Get arguments + $args = func_get_args(); + if (count($args) < 3) { + trigger_error('wrong parameter count for array_uintersect_uassoc()', E_USER_WARNING); + return; + } + + // Get callback functions + $user_func_item = array_pop($args); + $user_func_key = array_pop($args); + + if (is_array($user_func_item) && count($user_func_item) === 2) { + $user_func_item = current($user_func_item) . '::' . current($user_func_item); + } + if (!is_callable($user_func_item)) { + trigger_error('array_uintersect_uassoc() Not a valid callback ' . $user_func_item, E_USER_WARNING); + return; + } + if (is_array($user_func_key) && count($user_func_key) === 2) { + $user_func_key = current($user_func_key) . '::' . current($user_func_key); + } + if (!is_callable($user_func_key)) { + trigger_error('array_uintersect_uassoc() Not a valid callback ' . $user_func_key, E_USER_WARNING); + return; + } + + // Check arrays + $array_count = count($args); + + for ($i = 0; $i !== $array_count; $i++) { + + if (!is_array($args[$i])) { + trigger_error('array_uintersect_uassoc() [...]: Argument #' . ($i + 1) . ' is not an array', E_USER_WARNING); + return; + } + + } + + // Compare entries + $output = array(); + foreach ($args[0] as $key => $item) { + + for ($i = 1; $i !== $array_count; $i++) { + + $array = $args[$i]; + + foreach($array as $key0 => $item0) { + + if (!call_user_func($user_func_key, $key, $key0) && + !call_user_func($user_func_item, $item, $item0)) { + + $output[$key] = $item; + + } + + } + } + } + + return $output; } }