mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Added php tags (<?php ?>) to examples.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@129443 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
17fdae93ba
commit
736a15f139
28 changed files with 102 additions and 28 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.113 -->
|
||||
<refentry id="function.array-change-key-case">
|
||||
<refnamediv>
|
||||
|
@ -28,8 +28,10 @@
|
|||
<title><function>array_change_key_case</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$input_array = array("FirSt" => 1, "SecOnd" => 4);
|
||||
print_r(array_change_key_case($input_array, CASE_UPPER));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.array-chunk">
|
||||
<refnamediv>
|
||||
|
@ -33,9 +33,11 @@
|
|||
<title><function>array_chunk</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$input_array = array('a', 'b', 'c', 'd', 'e');
|
||||
print_r(array_chunk($input_array, 2));
|
||||
print_r(array_chunk($input_array, 2, TRUE));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.array-count-values">
|
||||
<refnamediv>
|
||||
|
@ -22,8 +22,10 @@
|
|||
<title><function>array_count_values</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$array = array (1, "hello", 1, "world", "hello");
|
||||
print_r(array_count_values ($array));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.array-fill">
|
||||
<refnamediv>
|
||||
|
@ -27,8 +27,10 @@
|
|||
<title><function>array_fill</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = array_fill(5, 6, 'banana');
|
||||
print_r($a);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<!-- $Revision: 1.10 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.62 -->
|
||||
<refentry id="function.array-filter">
|
||||
<refnamediv>
|
||||
|
@ -28,6 +28,7 @@
|
|||
<title><function>array_filter</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function odd($var) {
|
||||
return ($var % 2 == 1);
|
||||
}
|
||||
|
@ -43,6 +44,7 @@ echo "Odd :\n";
|
|||
print_r(array_filter($array1, "odd"));
|
||||
echo "Even:\n";
|
||||
print_r(array_filter($array2, "even"));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.107 -->
|
||||
<refentry id="function.array-flip">
|
||||
<refnamediv>
|
||||
|
@ -37,8 +37,10 @@
|
|||
<title><function>array_flip</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$trans = array_flip ($trans);
|
||||
$original = strtr ($str, $trans);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@ -48,9 +50,11 @@ $original = strtr ($str, $trans);
|
|||
<title><function>array_flip</function> example : collision</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$trans = array ("a" => 1, "b" => 1, "c" => 2);
|
||||
$trans = array_flip ($trans);
|
||||
print_r($trans);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
|
||||
<refentry id="function.array-intersect">
|
||||
<refnamediv>
|
||||
|
@ -25,9 +25,11 @@
|
|||
<title><function>array_intersect</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$array1 = array ("a" => "green", "red", "blue");
|
||||
$array2 = array ("b" => "green", "yellow", "red");
|
||||
$result = array_intersect ($array1, $array2);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.119 -->
|
||||
<refentry id="function.array-key-exists">
|
||||
<refnamediv>
|
||||
|
@ -24,10 +24,12 @@
|
|||
<title><function>array_key_exists</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$search_array = array("first" => 1, "second" => 4);
|
||||
if (array_key_exists("first", $search_array)) {
|
||||
echo "The 'first' element is in the array";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.12 -->
|
||||
<refentry id="function.array-merge-recursive">
|
||||
<refnamediv>
|
||||
|
@ -32,9 +32,11 @@
|
|||
<title><function>array_merge_recursive</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$ar1 = array ("color" => array ("favorite" => "red"), 5);
|
||||
$ar2 = array (10, "color" => array ("favorite" => "green", "blue"));
|
||||
$result = array_merge_recursive ($ar1, $ar2);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.array-merge">
|
||||
<refnamediv>
|
||||
|
@ -31,10 +31,12 @@
|
|||
<title><function>array_merge</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$array1 = array ("color" => "red", 2, 4);
|
||||
$array2 = array ("a", "b", "color" => "green", "shape" => "trapezoid", 4);
|
||||
$result = array_merge ($array1, $array2);
|
||||
print_r($result);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
@ -61,9 +63,11 @@ Array
|
|||
<title>Simple <function>array_merge</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$array1 = array();
|
||||
$array2 = array(1 => "data");
|
||||
$result = array_merge($array1, $array2);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
@ -82,9 +86,11 @@ Array
|
|||
them to each other, use the <literal>+</literal> operator:
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$array1 = array();
|
||||
$array2 = array(1 => "data");
|
||||
$result = $array1 + $array2;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
The numeric key will be preserved and thus the association remains.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.11 -->
|
||||
<refentry id="function.array-multisort">
|
||||
<refnamediv>
|
||||
|
@ -72,9 +72,11 @@
|
|||
<title>Sorting multiple arrays</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$ar1 = array ("10", 100, 100, "a");
|
||||
$ar2 = array (1, 3, "2", 1);
|
||||
array_multisort ($ar1, $ar2);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@ -90,9 +92,11 @@ array_multisort ($ar1, $ar2);
|
|||
<title>Sorting multi-dimensional array</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$ar = array (array ("10", 100, 100, "a"), array (1, 3, "2", 1));
|
||||
array_multisort ($ar[0], SORT_ASC, SORT_STRING,
|
||||
$ar[1], SORT_NUMERIC, SORT_DESC);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.array-pad">
|
||||
<refnamediv>
|
||||
|
@ -32,6 +32,7 @@
|
|||
<title><function>array_pad</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$input = array (12, 10, 9);
|
||||
|
||||
$result = array_pad ($input, 5, 0);
|
||||
|
@ -42,6 +43,7 @@ $result = array_pad ($input, -7, -1);
|
|||
|
||||
$result = array_pad ($input, 2, "noop");
|
||||
// not padded
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.array-push">
|
||||
<refnamediv>
|
||||
|
@ -24,7 +24,9 @@
|
|||
variables pushed. Has the same effect as:
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$array[] = $var;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
repeated for each <parameter>var</parameter>.
|
||||
|
@ -37,9 +39,11 @@ $array[] = $var;
|
|||
<title><function>array_push</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$stack = array ("orange", "banana");
|
||||
array_push ($stack, "apple", "raspberry");
|
||||
print_r($stack);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.array-reduce">
|
||||
<refnamediv>
|
||||
|
@ -30,6 +30,7 @@
|
|||
<title><function>array_reduce</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function rsum($v, $w) {
|
||||
$v += $w;
|
||||
return $v;
|
||||
|
@ -45,6 +46,7 @@ $x = array();
|
|||
$b = array_reduce($a, "rsum");
|
||||
$c = array_reduce($a, "rmul", 10);
|
||||
$d = array_reduce($x, "rsum", 1);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.array-slice">
|
||||
<refnamediv>
|
||||
|
@ -47,12 +47,14 @@
|
|||
<title><function>array_slice</function> examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$input = array ("a", "b", "c", "d", "e");
|
||||
|
||||
$output = array_slice ($input, 2); // returns "c", "d", and "e"
|
||||
$output = array_slice ($input, 2, -1); // returns "c", "d"
|
||||
$output = array_slice ($input, -2, 1); // returns "d"
|
||||
$output = array_slice ($input, 0, 3); // returns "a", "b", and "c"
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.14 -->
|
||||
<refentry id="function.array-splice">
|
||||
<refnamediv>
|
||||
|
@ -117,6 +117,7 @@
|
|||
<title><function>array_splice</function> examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$input = array ("red", "green", "blue", "yellow");
|
||||
array_splice ($input, 2);
|
||||
// $input is now array ("red", "green")
|
||||
|
@ -133,6 +134,7 @@ $input = array ("red", "green", "blue", "yellow");
|
|||
array_splice ($input, -1, 1, array("black", "maroon"));
|
||||
// $input is now array ("red", "green",
|
||||
// "blue", "black", "maroon")
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.59 -->
|
||||
<refentry id="function.array-sum">
|
||||
<refnamediv>
|
||||
|
@ -23,11 +23,13 @@
|
|||
<title><function>array_sum</function> examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = array(2, 4, 6, 8);
|
||||
echo "sum(a) = ".array_sum($a)."\n";
|
||||
|
||||
$b = array("a"=>1.2,"b"=>2.3,"c"=>3.4);
|
||||
echo "sum(b) = ".array_sum($b)."\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.array-unshift">
|
||||
<refnamediv>
|
||||
|
@ -34,8 +34,10 @@
|
|||
<title><function>array_unshift</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$queue = array ("orange", "banana");
|
||||
array_unshift ($queue, "apple", "raspberry");
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.arsort">
|
||||
<refnamediv>
|
||||
|
@ -25,12 +25,14 @@
|
|||
<title><function>arsort</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
|
||||
arsort ($fruits);
|
||||
reset ($fruits);
|
||||
while (list ($key, $val) = each ($fruits)) {
|
||||
echo "$key = $val\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.asort">
|
||||
<refnamediv>
|
||||
|
@ -23,12 +23,14 @@
|
|||
<title><function>asort</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
|
||||
asort ($fruits);
|
||||
reset ($fruits);
|
||||
while (list ($key, $val) = each ($fruits)) {
|
||||
echo "$key = $val\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.compact">
|
||||
<refnamediv>
|
||||
|
@ -38,6 +38,7 @@
|
|||
<title><function>compact</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$city = "San Francisco";
|
||||
$state = "CA";
|
||||
$event = "SIGGRAPH";
|
||||
|
@ -45,6 +46,7 @@ $event = "SIGGRAPH";
|
|||
$location_vars = array ("city", "state");
|
||||
|
||||
$result = compact ("event", "nothing_here", $location_vars);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.count">
|
||||
<refnamediv>
|
||||
|
@ -41,6 +41,7 @@
|
|||
<programlisting role="php">
|
||||
<!-- TODO: examples about count(null), count(false), count(object).. -->
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a[0] = 1;
|
||||
$a[1] = 3;
|
||||
$a[2] = 5;
|
||||
|
@ -52,6 +53,7 @@ $b[5] = 9;
|
|||
$b[10] = 11;
|
||||
$result = count ($b);
|
||||
// $result == 3;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.each">
|
||||
<refnamediv>
|
||||
|
@ -36,9 +36,11 @@
|
|||
<title><function>each</function> examples</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$foo = array ("bob", "fred", "jussi", "jouni", "egon", "marliese");
|
||||
$bar = each ($foo);
|
||||
print_r($bar);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
|
@ -57,9 +59,11 @@ Array
|
|||
</screen>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$foo = array ("Robert" => "Bob", "Seppo" => "Sepi");
|
||||
$bar = each ($foo);
|
||||
print_r($bar);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</para>
|
||||
|
@ -91,11 +95,13 @@ Array
|
|||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
echo "Values submitted via POST method:<br />\n";
|
||||
reset ($_POST);
|
||||
while (list ($key, $val) = each ($_POST)) {
|
||||
echo "$key => $val<br />\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.krsort">
|
||||
<refnamediv>
|
||||
|
@ -20,12 +20,14 @@
|
|||
<title><function>krsort</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$fruits = array ("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple");
|
||||
krsort ($fruits);
|
||||
reset ($fruits);
|
||||
while (list ($key, $val) = each ($fruits)) {
|
||||
echo "$key = $val\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.rsort">
|
||||
<refnamediv>
|
||||
|
@ -19,12 +19,14 @@
|
|||
<title><function>rsort</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$fruits = array ("lemon", "orange", "banana", "apple");
|
||||
rsort ($fruits);
|
||||
reset ($fruits);
|
||||
while (list ($key, $val) = each ($fruits)) {
|
||||
echo "$key = $val\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.shuffle">
|
||||
<refnamediv>
|
||||
|
@ -20,12 +20,14 @@
|
|||
<title><function>shuffle</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$numbers = range (1,20);
|
||||
srand ((float)microtime()*1000000);
|
||||
shuffle ($numbers);
|
||||
while (list (, $number) = each ($numbers)) {
|
||||
echo "$number ";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.uksort">
|
||||
<refnamediv>
|
||||
|
@ -25,6 +25,7 @@
|
|||
<title><function>uksort</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function cmp ($a, $b) {
|
||||
if ($a == $b) return 0;
|
||||
return ($a > $b) ? -1 : 1;
|
||||
|
@ -37,6 +38,7 @@ uksort ($a, "cmp");
|
|||
while (list ($key, $value) = each ($a)) {
|
||||
echo "$key: $value\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<!-- $Revision: 1.10 $ -->
|
||||
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.usort">
|
||||
<refnamediv>
|
||||
|
@ -40,6 +40,7 @@
|
|||
<title><function>usort</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function cmp ($a, $b) {
|
||||
if ($a == $b) return 0;
|
||||
return ($a < $b) ? -1 : 1;
|
||||
|
@ -52,6 +53,7 @@ usort ($a, "cmp");
|
|||
while (list ($key, $value) = each ($a)) {
|
||||
echo "$key: $value\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@ -83,6 +85,7 @@ while (list ($key, $value) = each ($a)) {
|
|||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function cmp ($a, $b) {
|
||||
return strcmp($a["fruit"], $b["fruit"]);
|
||||
}
|
||||
|
@ -96,6 +99,7 @@ usort($fruits, "cmp");
|
|||
while (list ($key, $value) = each ($fruits)) {
|
||||
echo "\$fruits[$key]: " . $value["fruit"] . "\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@ -124,6 +128,7 @@ $fruits[2]: lemons
|
|||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
class TestObj {
|
||||
var $name;
|
||||
|
||||
|
@ -151,6 +156,7 @@ uasort($a, array ("TestObj", "cmp_obj"));
|
|||
foreach ($a as $item) {
|
||||
print $item->name."\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
Loading…
Reference in a new issue