mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
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
This commit is contained in:
parent
8c0a7169e9
commit
7e29802d31
5 changed files with 83 additions and 64 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
|
||||
<refentry id="function.array-diff-assoc">
|
||||
<refnamediv>
|
||||
|
@ -18,7 +18,7 @@
|
|||
<function>array_diff_assoc</function> returns an <type>array</type>
|
||||
containing all the values from <parameter>array1</parameter>
|
||||
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
|
||||
<function>array_diff</function>.
|
||||
</para>
|
||||
<para>
|
||||
|
@ -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);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The result is:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Array
|
||||
(
|
||||
[b] => brown
|
||||
[c] => blue
|
||||
[0] => red
|
||||
)
|
||||
*/
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
|
||||
<refentry id="function.array-diff-uassoc">
|
||||
<refnamediv>
|
||||
|
@ -19,7 +19,7 @@
|
|||
<function>array_diff_uassoc</function> returns an <type>array</type>
|
||||
containing all the values from <parameter>array1</parameter>
|
||||
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
|
||||
<function>array_diff</function>. 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 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
function key_compare_func($a, $b) {
|
||||
if ($a === $b) return 0;
|
||||
return ($a > $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:
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The result is:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Array
|
||||
(
|
||||
[b] => brown
|
||||
[c] => blue
|
||||
[0] => red
|
||||
)
|
||||
*/
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
In our example above you see the <literal>"a" => "green"</literal>
|
||||
pair is present in both arrays and thus it is not in the ouput from the
|
||||
function. Unlike this, the pair <literal>0 => "red"</literal>
|
||||
function. Unlike this, the pair <literal>0 => "red"</literal>
|
||||
is in the ouput because in the second argument <literal>"red"</literal>
|
||||
has key which is <literal>1</literal>.
|
||||
has key which is <literal>1</literal>.
|
||||
</simpara>
|
||||
<simpara>
|
||||
The equality of 2 indices is checked by the user supplied callback function.
|
||||
|
@ -68,7 +72,7 @@ Array
|
|||
<note>
|
||||
<simpara>
|
||||
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,
|
||||
<literal>array_diff_uassoc($array1[0], $array2[0], "key_compare_func");</literal>.
|
||||
</simpara>
|
||||
</note>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
|
||||
<refentry id="function.array-udiff-assoc">
|
||||
<refnamediv>
|
||||
|
@ -33,14 +33,14 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
class cr {
|
||||
private $priv_member;
|
||||
private $priv_member;
|
||||
function cr($val) {
|
||||
$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;
|
||||
}
|
||||
$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:
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The result is:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Array
|
||||
(
|
||||
[0.1] => cr Object
|
||||
|
@ -67,16 +72,14 @@ Array
|
|||
[priv_member:private] => 23
|
||||
)
|
||||
)
|
||||
*/
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
In our example above you see the <literal>"1" => new cr(4)</literal>
|
||||
pair is present in both arrays and thus it is not in the ouput from the
|
||||
function.
|
||||
function.
|
||||
</simpara>
|
||||
<simpara>
|
||||
For comparison is used the user supplied callback function.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
|
||||
<refentry id="function.array-udiff-uassoc">
|
||||
<refnamediv>
|
||||
|
@ -38,18 +38,18 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
class cr {
|
||||
private $priv_member;
|
||||
private $priv_member;
|
||||
function cr($val) {
|
||||
$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;
|
||||
}
|
||||
$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:
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The result is:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Array
|
||||
(
|
||||
[0.1] => cr Object
|
||||
|
@ -76,16 +81,14 @@ Array
|
|||
[priv_member:private] => 23
|
||||
)
|
||||
)
|
||||
*/
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<simpara>
|
||||
In our example above you see the <literal>"1" => new cr(4)</literal>
|
||||
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.
|
||||
</simpara>
|
||||
<simpara>
|
||||
For comparison is used the user supplied callback function.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
|
||||
<refentry id="function.array-udiff">
|
||||
<refnamediv>
|
||||
|
@ -34,22 +34,28 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
class cr {
|
||||
private $priv_member;
|
||||
private $priv_member;
|
||||
function cr($val) {
|
||||
$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;
|
||||
}
|
||||
$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:
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The result is:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Array
|
||||
(
|
||||
[0.5] => cr Object
|
||||
|
@ -63,10 +69,8 @@ Array
|
|||
)
|
||||
|
||||
)
|
||||
*/
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
|
|
Loading…
Reference in a new issue