From 7e29802d319b92feeda4cb5c19b301f75fa9c4bc Mon Sep 17 00:00:00 2001 From: Mehdi Achour Date: Mon, 3 Nov 2003 14:05:07 +0000 Subject: [PATCH] using screen tag for the examples converting tabs to spaces in the examples there is some noise with WS that I was unable to reduce, but my WS seems to be ok git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@143671 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../array/functions/array-diff-assoc.xml | 19 +++++---- .../array/functions/array-diff-uassoc.xml | 28 +++++++------ .../array/functions/array-udiff-assoc.xml | 31 ++++++++------- .../array/functions/array-udiff-uassoc.xml | 39 ++++++++++--------- reference/array/functions/array-udiff.xml | 30 +++++++------- 5 files changed, 83 insertions(+), 64 deletions(-) diff --git a/reference/array/functions/array-diff-assoc.xml b/reference/array/functions/array-diff-assoc.xml index 7c4d4dc631..12276f8815 100644 --- a/reference/array/functions/array-diff-assoc.xml +++ b/reference/array/functions/array-diff-assoc.xml @@ -1,5 +1,5 @@ - + @@ -18,7 +18,7 @@ array_diff_assoc returns an array containing all the values from array1 that are not present in any of the other arguments. - Note that the keys are used in the comparison unlike + Note that the keys are used in the comparison unlike array_diff. @@ -30,18 +30,23 @@ $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = array_diff_assoc($array1, $array2); - -/* The result is: +print_r($result); +?> +]]> + + + The result is: + + + brown [c] => blue [0] => red ) -*/ -?> ]]> - + diff --git a/reference/array/functions/array-diff-uassoc.xml b/reference/array/functions/array-diff-uassoc.xml index 9a7998faec..70edae452d 100644 --- a/reference/array/functions/array-diff-uassoc.xml +++ b/reference/array/functions/array-diff-uassoc.xml @@ -1,5 +1,5 @@ - + @@ -19,7 +19,7 @@ array_diff_uassoc returns an array containing all the values from array1 that are not present in any of the other arguments. - Note that the keys are used in the comparison unlike + Note that the keys are used in the comparison unlike array_diff. This comparison is done by a user supplied callback function. It must return an integer less than, equal to, or greater than zero if the first argument is considered to @@ -34,33 +34,37 @@ $b)? 1:-1; + if ($a === $b) return 0; + return ($a > $b)? 1:-1; } $array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array("a" => "green", "yellow", "red"); $result = array_diff_uassoc($array1, $array2, "key_compare_func"); - -/* The result is: +?> +]]> + + + The result is: + + + brown [c] => blue [0] => red ) -*/ -?> ]]> - + In our example above you see the "a" => "green" pair is present in both arrays and thus it is not in the ouput from the - function. Unlike this, the pair 0 => "red" + function. Unlike this, the pair 0 => "red" is in the ouput because in the second argument "red" - has key which is 1. + has key which is 1. The equality of 2 indices is checked by the user supplied callback function. @@ -68,7 +72,7 @@ Array Please note that this function only checks one dimension of a n-dimensional - array. Of course you can check deeper dimensions by using, for example, + array. Of course you can check deeper dimensions by using, for example, array_diff_uassoc($array1[0], $array2[0], "key_compare_func");. diff --git a/reference/array/functions/array-udiff-assoc.xml b/reference/array/functions/array-udiff-assoc.xml index eb9bda95e1..ca99b6c44b 100644 --- a/reference/array/functions/array-udiff-assoc.xml +++ b/reference/array/functions/array-udiff-assoc.xml @@ -1,5 +1,5 @@ - + @@ -33,14 +33,14 @@ priv_member = $val; - } - static function comp_func_cr($a, $b) { - if ($a->priv_member === $b->priv_member) return 0; - return ($a->priv_member > $b->priv_member)? 1:-1; - } + $this->priv_member = $val; + } + static function comp_func_cr($a, $b) { + if ($a->priv_member === $b->priv_member) return 0; + return ($a->priv_member > $b->priv_member)? 1:-1; + } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr( 3), 1=> new cr(4), 2 => new cr(-15),); @@ -48,8 +48,13 @@ $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr( 3), 1=> new cr( $result = array_udiff_assoc($a, $b, array("cr", "comp_func_cr")); print_r($result); ?> - -/* The result is: +]]> + + + The result is: + + + cr Object @@ -67,16 +72,14 @@ Array [priv_member:private] => 23 ) ) -*/ -?> ]]> - + In our example above you see the "1" => new cr(4) pair is present in both arrays and thus it is not in the ouput from the - function. + function. For comparison is used the user supplied callback function. diff --git a/reference/array/functions/array-udiff-uassoc.xml b/reference/array/functions/array-udiff-uassoc.xml index d81172ec72..6a6a46eee3 100644 --- a/reference/array/functions/array-udiff-uassoc.xml +++ b/reference/array/functions/array-udiff-uassoc.xml @@ -1,5 +1,5 @@ - + @@ -38,18 +38,18 @@ priv_member = $val; - } - static function comp_func_cr($a, $b) { - if ($a->priv_member === $b->priv_member) return 0; - return ($a->priv_member > $b->priv_member)? 1:-1; - } - static function comp_func_key($a, $b) { - if ($a === $b) return 0; - return ($a > $b)? 1:-1; - } + $this->priv_member = $val; + } + static function comp_func_cr($a, $b) { + if ($a->priv_member === $b->priv_member) return 0; + return ($a->priv_member > $b->priv_member)? 1:-1; + } + static function comp_func_key($a, $b) { + if ($a === $b) return 0; + return ($a > $b)? 1:-1; + } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr( 3), 1=> new cr(4), 2 => new cr(-15),); @@ -57,8 +57,13 @@ $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr( 3), 1=> new cr( $result = array_udiff_uassoc($a, $b, array("cr", "comp_func_cr"), array("cr","comp_func_key")); print_r($result); ?> - -/* The result is: +]]> + + + The result is: + + + cr Object @@ -76,16 +81,14 @@ Array [priv_member:private] => 23 ) ) -*/ -?> ]]> - + In our example above you see the "1" => new cr(4) pair is present in both arrays and thus it is not in the ouput from the - function. Keep in mind that you have to supply 2 callback functions. + function. Keep in mind that you have to supply 2 callback functions. For comparison is used the user supplied callback function. diff --git a/reference/array/functions/array-udiff.xml b/reference/array/functions/array-udiff.xml index ee736f3fd6..de3169b68f 100644 --- a/reference/array/functions/array-udiff.xml +++ b/reference/array/functions/array-udiff.xml @@ -1,5 +1,5 @@ - + @@ -34,22 +34,28 @@ priv_member = $val; - } - static function comp_func_cr($a, $b) { - if ($a->priv_member === $b->priv_member) return 0; - return ($a->priv_member > $b->priv_member)? 1:-1; - } + $this->priv_member = $val; + } + static function comp_func_cr($a, $b) { + if ($a->priv_member === $b->priv_member) return 0; + return ($a->priv_member > $b->priv_member)? 1:-1; + } } $a = array("0.1" => new cr(9), "0.5" => new cr(12), 0 => new cr(23), 1=> new cr(4), 2 => new cr(-15),); $b = array("0.2" => new cr(9), "0.5" => new cr(22), 0 => new cr( 3), 1=> new cr(4), 2 => new cr(-15),); $result = array_udiff($a, $b, array("cr", "comp_func_cr")); print_r($result); - -/* The result is: +?> +]]> + + + The result is: + + + cr Object @@ -63,10 +69,8 @@ Array ) ) -*/ -?> ]]> - +