From 23396d4d4ed8a258636bdb4d13997567f94450a6 Mon Sep 17 00:00:00 2001 From: "Heilig (Cece) Szabolcs" Date: Sun, 17 Aug 2003 12:21:03 +0000 Subject: [PATCH] applying PEAR coding standards on examples git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@138081 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/array/functions/array-combine.xml | 6 ++-- .../array/functions/array-count-values.xml | 6 ++-- .../array/functions/array-diff-assoc.xml | 8 ++--- reference/array/functions/array-diff.xml | 8 ++--- reference/array/functions/array-filter.xml | 10 +++--- reference/array/functions/array-flip.xml | 10 +++--- .../array/functions/array-intersect-assoc.xml | 8 ++--- reference/array/functions/array-intersect.xml | 8 ++--- reference/array/functions/array-keys.xml | 16 +++++----- reference/array/functions/array-map.xml | 8 ++--- .../array/functions/array-merge-recursive.xml | 8 ++--- reference/array/functions/array-merge.xml | 8 ++--- reference/array/functions/array-multisort.xml | 14 ++++---- reference/array/functions/array-pad.xml | 14 ++++---- reference/array/functions/array-pop.xml | 6 ++-- reference/array/functions/array-push.xml | 6 ++-- reference/array/functions/array-rand.xml | 12 +++---- reference/array/functions/array-reverse.xml | 8 ++--- reference/array/functions/array-shift.xml | 6 ++-- reference/array/functions/array-slice.xml | 10 +++--- reference/array/functions/array-splice.xml | 32 +++++++++---------- reference/array/functions/array-unique.xml | 10 +++--- reference/array/functions/array-unshift.xml | 6 ++-- reference/array/functions/array-values.xml | 4 +-- reference/array/functions/array-walk.xml | 14 ++++---- reference/array/functions/array.xml | 12 +++---- reference/array/functions/arsort.xml | 10 +++--- reference/array/functions/asort.xml | 10 +++--- reference/array/functions/compact.xml | 8 ++--- reference/array/functions/count.xml | 14 ++++---- reference/array/functions/each.xml | 14 ++++---- reference/array/functions/end.xml | 4 +-- reference/array/functions/extract.xml | 10 +++--- reference/array/functions/in-array.xml | 12 +++---- reference/array/functions/key.xml | 15 ++++----- reference/array/functions/krsort.xml | 10 +++--- reference/array/functions/ksort.xml | 10 +++--- reference/array/functions/list.xml | 14 ++++---- reference/array/functions/natsort.xml | 4 +-- reference/array/functions/range.xml | 10 +++--- reference/array/functions/rsort.xml | 10 +++--- reference/array/functions/shuffle.xml | 10 +++--- reference/array/functions/sort.xml | 10 +++--- reference/array/functions/uksort.xml | 14 ++++---- reference/array/functions/usort.xml | 24 ++++++++------ 45 files changed, 238 insertions(+), 233 deletions(-) diff --git a/reference/array/functions/array-combine.xml b/reference/array/functions/array-combine.xml index 2999f2060d..822f33ca8f 100644 --- a/reference/array/functions/array-combine.xml +++ b/reference/array/functions/array-combine.xml @@ -1,5 +1,5 @@ - + array_combine @@ -29,8 +29,8 @@ - + @@ -23,8 +23,8 @@ ]]> diff --git a/reference/array/functions/array-diff-assoc.xml b/reference/array/functions/array-diff-assoc.xml index eb3a91830e..7c4d4dc631 100644 --- a/reference/array/functions/array-diff-assoc.xml +++ b/reference/array/functions/array-diff-assoc.xml @@ -1,5 +1,5 @@ - + @@ -27,9 +27,9 @@ "green", "b" => "brown", "c" => "blue", "red"); -$array2 = array ("a" => "green", "yellow", "red"); -$result = array_diff_assoc ($array1, $array2); +$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); +$array2 = array("a" => "green", "yellow", "red"); +$result = array_diff_assoc($array1, $array2); /* The result is: Array diff --git a/reference/array/functions/array-diff.xml b/reference/array/functions/array-diff.xml index 3db9f57526..035a3f0ce5 100644 --- a/reference/array/functions/array-diff.xml +++ b/reference/array/functions/array-diff.xml @@ -1,5 +1,5 @@ - + @@ -26,9 +26,9 @@ "green", "red", "blue", "red"); -$array2 = array ("b" => "green", "yellow", "red"); -$result = array_diff ($array1, $array2); +$array1 = array("a" => "green", "red", "blue", "red"); +$array2 = array("b" => "green", "yellow", "red"); +$result = array_diff($array1, $array2); ?> ]]> diff --git a/reference/array/functions/array-filter.xml b/reference/array/functions/array-filter.xml index ca92291a75..24be7ba8c6 100644 --- a/reference/array/functions/array-filter.xml +++ b/reference/array/functions/array-filter.xml @@ -1,5 +1,5 @@ - + @@ -30,15 +30,15 @@ 1, "b"=>2, "c"=>3, "d"=>4, "e"=>5); -$array2 = array (6, 7, 8, 9, 10, 11, 12); +$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5); +$array2 = array(6, 7, 8, 9, 10, 11, 12); echo "Odd :\n"; print_r(array_filter($array1, "odd")); diff --git a/reference/array/functions/array-flip.xml b/reference/array/functions/array-flip.xml index 0940ba6612..f1ae36dca8 100644 --- a/reference/array/functions/array-flip.xml +++ b/reference/array/functions/array-flip.xml @@ -1,5 +1,5 @@ - + @@ -38,8 +38,8 @@ ]]> @@ -51,8 +51,8 @@ $original = strtr ($str, $trans); 1, "b" => 1, "c" => 2); -$trans = array_flip ($trans); +$trans = array("a" => 1, "b" => 1, "c" => 2); +$trans = array_flip($trans); print_r($trans); ?> ]]> diff --git a/reference/array/functions/array-intersect-assoc.xml b/reference/array/functions/array-intersect-assoc.xml index fe330eb51b..c22f402245 100644 --- a/reference/array/functions/array-intersect-assoc.xml +++ b/reference/array/functions/array-intersect-assoc.xml @@ -1,5 +1,5 @@ - + array_intersect_assoc @@ -25,9 +25,9 @@ "green", "b" => "brown", "c" => "blue", "red"); -$array2 = array ("a" => "green", "yellow", "red"); -$result_array = array_intersect_assoc ($array1, $array2); +$array1 = array("a" => "green", "b" => "brown", "c" => "blue", "red"); +$array2 = array("a" => "green", "yellow", "red"); +$result_array = array_intersect_assoc($array1, $array2); /* $result_array will look like: diff --git a/reference/array/functions/array-intersect.xml b/reference/array/functions/array-intersect.xml index 60b28c7168..661502747f 100644 --- a/reference/array/functions/array-intersect.xml +++ b/reference/array/functions/array-intersect.xml @@ -1,5 +1,5 @@ - + @@ -26,9 +26,9 @@ "green", "red", "blue"); -$array2 = array ("b" => "green", "yellow", "red"); -$result = array_intersect ($array1, $array2); +$array1 = array("a" => "green", "red", "blue"); +$array2 = array("b" => "green", "yellow", "red"); +$result = array_intersect($array1, $array2); ?> ]]> diff --git a/reference/array/functions/array-keys.xml b/reference/array/functions/array-keys.xml index 4925cf80a6..ce1052814f 100644 --- a/reference/array/functions/array-keys.xml +++ b/reference/array/functions/array-keys.xml @@ -1,5 +1,5 @@ - + @@ -30,15 +30,15 @@ 100, "color" => "red"); -print_r(array_keys ($array)); +$array = array(0 => 100, "color" => "red"); +print_r(array_keys($array)); -$array = array ("blue", "red", "green", "blue", "blue"); -print_r(array_keys ($array, "blue")); +$array = array("blue", "red", "green", "blue", "blue"); +print_r(array_keys($array, "blue")); -$array = array ("color" => array("blue", "red", "green"), - "size" => array("small", "medium", "large")); -print_r(array_keys ($array)); +$array = array("color" => array("blue", "red", "green"), + "size" => array("small", "medium", "large")); +print_r(array_keys($array)); ?> ]]> diff --git a/reference/array/functions/array-map.xml b/reference/array/functions/array-map.xml index c812b227c9..028576d6f7 100644 --- a/reference/array/functions/array-map.xml +++ b/reference/array/functions/array-map.xml @@ -1,5 +1,5 @@ - + @@ -32,7 +32,7 @@ $m); + return(array($n => $m)); } $a = array(1, 2, 3, 4, 5); diff --git a/reference/array/functions/array-merge-recursive.xml b/reference/array/functions/array-merge-recursive.xml index ebaf47be38..9542ddb1ae 100644 --- a/reference/array/functions/array-merge-recursive.xml +++ b/reference/array/functions/array-merge-recursive.xml @@ -1,5 +1,5 @@ - + @@ -33,9 +33,9 @@ array ("favorite" => "red"), 5); -$ar2 = array (10, "color" => array ("favorite" => "green", "blue")); -$result = array_merge_recursive ($ar1, $ar2); +$ar1 = array("color" => array("favorite" => "red"), 5); +$ar2 = array(10, "color" => array("favorite" => "green", "blue")); +$result = array_merge_recursive($ar1, $ar2); ?> ]]> diff --git a/reference/array/functions/array-merge.xml b/reference/array/functions/array-merge.xml index 3edb4241bf..efd6fe5211 100644 --- a/reference/array/functions/array-merge.xml +++ b/reference/array/functions/array-merge.xml @@ -1,5 +1,5 @@ - + @@ -32,9 +32,9 @@ "red", 2, 4); -$array2 = array ("a", "b", "color" => "green", "shape" => "trapezoid", 4); -$result = array_merge ($array1, $array2); +$array1 = array("color" => "red", 2, 4); +$array2 = array("a", "b", "color" => "green", "shape" => "trapezoid", 4); +$result = array_merge($array1, $array2); print_r($result); ?> ]]> diff --git a/reference/array/functions/array-multisort.xml b/reference/array/functions/array-multisort.xml index 88469dbc64..c133850576 100644 --- a/reference/array/functions/array-multisort.xml +++ b/reference/array/functions/array-multisort.xml @@ -1,5 +1,5 @@ - + @@ -73,9 +73,9 @@ ]]> @@ -93,9 +93,9 @@ array_multisort ($ar1, $ar2); ]]> diff --git a/reference/array/functions/array-pad.xml b/reference/array/functions/array-pad.xml index 0babbaf9f8..972b7af036 100644 --- a/reference/array/functions/array-pad.xml +++ b/reference/array/functions/array-pad.xml @@ -1,5 +1,5 @@ - + @@ -33,15 +33,15 @@ ]]> diff --git a/reference/array/functions/array-pop.xml b/reference/array/functions/array-pop.xml index 9fc0a9648b..fd96547ec5 100644 --- a/reference/array/functions/array-pop.xml +++ b/reference/array/functions/array-pop.xml @@ -1,5 +1,5 @@ - + @@ -28,8 +28,8 @@ ]]> diff --git a/reference/array/functions/array-push.xml b/reference/array/functions/array-push.xml index c3a4a39fde..debf9c8f92 100644 --- a/reference/array/functions/array-push.xml +++ b/reference/array/functions/array-push.xml @@ -1,5 +1,5 @@ - + @@ -40,8 +40,8 @@ $array[] = $var; ]]> diff --git a/reference/array/functions/array-rand.xml b/reference/array/functions/array-rand.xml index c30658a18f..9d719f3e4a 100644 --- a/reference/array/functions/array-rand.xml +++ b/reference/array/functions/array-rand.xml @@ -1,5 +1,5 @@ - + @@ -37,11 +37,11 @@ ]]> diff --git a/reference/array/functions/array-reverse.xml b/reference/array/functions/array-reverse.xml index 4d9881c3b9..92279f7c36 100644 --- a/reference/array/functions/array-reverse.xml +++ b/reference/array/functions/array-reverse.xml @@ -1,5 +1,5 @@ - + @@ -27,9 +27,9 @@ ]]> diff --git a/reference/array/functions/array-shift.xml b/reference/array/functions/array-shift.xml index c308197205..620cd2de23 100644 --- a/reference/array/functions/array-shift.xml +++ b/reference/array/functions/array-shift.xml @@ -1,5 +1,5 @@ - + @@ -30,8 +30,8 @@ ]]> diff --git a/reference/array/functions/array-slice.xml b/reference/array/functions/array-slice.xml index 0416849fda..f787b334a7 100644 --- a/reference/array/functions/array-slice.xml +++ b/reference/array/functions/array-slice.xml @@ -1,5 +1,5 @@ - + @@ -50,10 +50,10 @@ ]]> diff --git a/reference/array/functions/array-splice.xml b/reference/array/functions/array-splice.xml index a993b3427a..dbc3a329a3 100644 --- a/reference/array/functions/array-splice.xml +++ b/reference/array/functions/array-splice.xml @@ -1,5 +1,5 @@ - + @@ -118,26 +118,26 @@ ]]> diff --git a/reference/array/functions/array-unique.xml b/reference/array/functions/array-unique.xml index ac8069256d..0b87575d7d 100644 --- a/reference/array/functions/array-unique.xml +++ b/reference/array/functions/array-unique.xml @@ -1,5 +1,5 @@ - + @@ -40,8 +40,8 @@ "green", "red", "b" => "green", "blue", "red"); -$result = array_unique ($input); +$input = array("a" => "green", "red", "b" => "green", "blue", "red"); +$result = array_unique($input); print_r($result); ?> ]]> @@ -67,8 +67,8 @@ Array ]]> diff --git a/reference/array/functions/array-unshift.xml b/reference/array/functions/array-unshift.xml index 0b1c4c6d1a..647227fb59 100644 --- a/reference/array/functions/array-unshift.xml +++ b/reference/array/functions/array-unshift.xml @@ -1,5 +1,5 @@ - + @@ -35,8 +35,8 @@ ]]> diff --git a/reference/array/functions/array-values.xml b/reference/array/functions/array-values.xml index e8eebaf673..863539d446 100644 --- a/reference/array/functions/array-values.xml +++ b/reference/array/functions/array-values.xml @@ -1,5 +1,5 @@ - + @@ -23,7 +23,7 @@ "XL", "color" => "gold"); +$array = array("size" => "XL", "color" => "gold"); print_r(array_values ($array)); ?> ]]> diff --git a/reference/array/functions/array-walk.xml b/reference/array/functions/array-walk.xml index 33fbc37652..eb6390fe3d 100644 --- a/reference/array/functions/array-walk.xml +++ b/reference/array/functions/array-walk.xml @@ -1,5 +1,5 @@ - + @@ -75,23 +75,23 @@ "lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); +$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); -function test_alter (&$item1, $key, $prefix) { +function test_alter(&$item1, $key, $prefix) { $item1 = "$prefix: $item1"; } -function test_print ($item2, $key) { +function test_print($item2, $key) { echo "$key. $item2
\n"; } echo "Before ...:\n"; -array_walk ($fruits, 'test_print'); +array_walk($fruits, 'test_print'); -array_walk ($fruits, 'test_alter', 'fruit'); +array_walk($fruits, 'test_alter', 'fruit'); echo "... and after:\n"; -array_walk ($fruits, 'test_print'); +array_walk($fruits, 'test_print'); ?> ]]>
diff --git a/reference/array/functions/array.xml b/reference/array/functions/array.xml index dce3d7c700..bbbc5372c7 100644 --- a/reference/array/functions/array.xml +++ b/reference/array/functions/array.xml @@ -1,5 +1,5 @@ - + @@ -47,9 +47,9 @@ array ("a"=>"orange", "b"=>"banana", "c"=>"apple"), - "numbers" => array (1, 2, 3, 4, 5, 6), - "holes" => array ("first", 5 => "second", "third") + "fruits" => array("a" => "orange", "b" => "banana", "c" => "apple"), + "numbers" => array(1, 2, 3, 4, 5, 6), + "holes" => array("first", 5 => "second", "third") ) ?> ]]> @@ -62,7 +62,7 @@ $fruits = array ( 1, 4=>1, 19, 3=>13); +$array = array(1, 1, 1, 1, 1, 8 => 1, 4 => 1, 19, 3 => 13); print_r($array); ?> ]]> @@ -98,7 +98,7 @@ Array 'January', 'February', 'March'); +$firstquarter = array(1 => 'January', 'February', 'March'); print_r($firstquarter); ?> ]]> diff --git a/reference/array/functions/arsort.xml b/reference/array/functions/arsort.xml index 982f7bf9b6..8e47239387 100644 --- a/reference/array/functions/arsort.xml +++ b/reference/array/functions/arsort.xml @@ -1,5 +1,5 @@ - + @@ -26,10 +26,10 @@ "lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); -arsort ($fruits); -reset ($fruits); -while (list ($key, $val) = each ($fruits)) { +$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); +arsort($fruits); +reset($fruits); +while (list($key, $val) = each($fruits)) { echo "$key = $val\n"; } ?> diff --git a/reference/array/functions/asort.xml b/reference/array/functions/asort.xml index aca130e028..f7f844a890 100644 --- a/reference/array/functions/asort.xml +++ b/reference/array/functions/asort.xml @@ -1,5 +1,5 @@ - + @@ -24,10 +24,10 @@ "lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); -asort ($fruits); -reset ($fruits); -while (list ($key, $val) = each ($fruits)) { +$fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); +asort($fruits); +reset($fruits); +while (list($key, $val) = each($fruits)) { echo "$key = $val\n"; } ?> diff --git a/reference/array/functions/compact.xml b/reference/array/functions/compact.xml index c2a45341c6..22151afc88 100644 --- a/reference/array/functions/compact.xml +++ b/reference/array/functions/compact.xml @@ -1,5 +1,5 @@ - + @@ -39,13 +39,13 @@ ]]> diff --git a/reference/array/functions/count.xml b/reference/array/functions/count.xml index 0d735095f4..8afb7840f3 100644 --- a/reference/array/functions/count.xml +++ b/reference/array/functions/count.xml @@ -1,5 +1,5 @@ - + @@ -59,13 +59,13 @@ $a[0] = 1; $a[1] = 3; $a[2] = 5; -$result = count ($a); +$result = count($a); // $result == 3 -$b[0] = 7; -$b[5] = 9; +$b[0] = 7; +$b[5] = 9; $b[10] = 11; -$result = count ($b); +$result = count($b); // $result == 3; ?> ]]> @@ -80,8 +80,8 @@ $result = count ($b); array('orange', 'banana', 'apple'), - 'veggie' => array('carrot', 'collard','pea')); +$food = array('fruits' => array('orange', 'banana', 'apple'), + 'veggie' => array('carrot', 'collard','pea')); // recursive count echo count($food,COUNT_RECURSIVE); // output 8 diff --git a/reference/array/functions/each.xml b/reference/array/functions/each.xml index 8b5bf98be2..ac0d344606 100644 --- a/reference/array/functions/each.xml +++ b/reference/array/functions/each.xml @@ -1,5 +1,5 @@ - + @@ -37,8 +37,8 @@ ]]> @@ -65,8 +65,8 @@ Array "Bob", "Seppo" => "Sepi"); -$bar = each ($foo); +$foo = array("Robert" => "Bob", "Seppo" => "Sepi"); +$bar = each($foo); print_r($bar); ?> ]]> @@ -99,8 +99,8 @@ Array 'apple', 'b' => 'banana', 'c' => 'cranberry'); -reset ($fruit); -while (list ($key, $val) = each ($fruit)) { +reset($fruit); +while (list($key, $val) = each($fruit)) { echo "$key => $val\n"; } diff --git a/reference/array/functions/end.xml b/reference/array/functions/end.xml index dba5d33128..21c6af601b 100644 --- a/reference/array/functions/end.xml +++ b/reference/array/functions/end.xml @@ -1,5 +1,5 @@ - + @@ -26,7 +26,7 @@ - + @@ -163,10 +163,10 @@ wddx_deserialize */ $size = "large"; -$var_array = array ("color" => "blue", - "size" => "medium", - "shape" => "sphere"); -extract ($var_array, EXTR_PREFIX_SAME, "wddx"); +$var_array = array("color" => "blue", + "size" => "medium", + "shape" => "sphere"); +extract($var_array, EXTR_PREFIX_SAME, "wddx"); print "$color, $size, $shape, $wddx_size\n"; diff --git a/reference/array/functions/in-array.xml b/reference/array/functions/in-array.xml index 8f11c023c9..2105c669db 100644 --- a/reference/array/functions/in-array.xml +++ b/reference/array/functions/in-array.xml @@ -1,5 +1,5 @@ - + @@ -43,11 +43,11 @@ @@ -100,11 +100,11 @@ if (in_array(1.13, $a, TRUE)) { - + @@ -22,13 +22,12 @@ 'apple', - 'fruit2' => 'orange', - 'fruit3' => 'grape', - 'fruit4' => 'apple', - 'fruit5' => 'apple' -); +$array = array( + 'fruit1' => 'apple', + 'fruit2' => 'orange', + 'fruit3' => 'grape', + 'fruit4' => 'apple', + 'fruit5' => 'apple'); // this cycle echoes all associative array // key where value equals "apple" diff --git a/reference/array/functions/krsort.xml b/reference/array/functions/krsort.xml index 0d64b7847f..2bec20533e 100644 --- a/reference/array/functions/krsort.xml +++ b/reference/array/functions/krsort.xml @@ -1,5 +1,5 @@ - + @@ -23,10 +23,10 @@ "lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); -krsort ($fruits); -reset ($fruits); -while (list ($key, $val) = each ($fruits)) { +$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); +krsort($fruits); +reset($fruits); +while (list($key, $val) = each($fruits)) { echo "$key = $val\n"; } ?> diff --git a/reference/array/functions/ksort.xml b/reference/array/functions/ksort.xml index b6e7f0b46f..a5eba2b242 100644 --- a/reference/array/functions/ksort.xml +++ b/reference/array/functions/ksort.xml @@ -1,5 +1,5 @@ - + @@ -23,10 +23,10 @@ "lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); -ksort ($fruits); -reset ($fruits); -while (list ($key, $val) = each ($fruits)) { +$fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); +ksort($fruits); +reset($fruits); +while (list($key, $val) = each($fruits)) { echo "$key = $val\n"; } ?> diff --git a/reference/array/functions/list.xml b/reference/array/functions/list.xml index 0131d78016..0409c53f14 100644 --- a/reference/array/functions/list.xml +++ b/reference/array/functions/list.xml @@ -1,5 +1,5 @@ - + @@ -64,12 +64,12 @@ print "I need $power!\n"; \n". - " $name\n". - " $salary\n". - " \n"); +$result = mysql_query("SELECT id, name, salary FROM employees",$conn); +while (list($id, $name, $salary) = mysql_fetch_row($result)) { + print(" \n" . + " $name\n" . + " $salary\n" . + " \n"); } ?> diff --git a/reference/array/functions/natsort.xml b/reference/array/functions/natsort.xml index 923af6167b..b5620a309a 100644 --- a/reference/array/functions/natsort.xml +++ b/reference/array/functions/natsort.xml @@ -1,5 +1,5 @@ - + @@ -27,7 +27,7 @@ - + @@ -39,23 +39,23 @@ - + @@ -22,10 +22,10 @@ diff --git a/reference/array/functions/shuffle.xml b/reference/array/functions/shuffle.xml index 79fe633aff..7e2078228a 100644 --- a/reference/array/functions/shuffle.xml +++ b/reference/array/functions/shuffle.xml @@ -1,5 +1,5 @@ - + @@ -21,10 +21,10 @@ diff --git a/reference/array/functions/sort.xml b/reference/array/functions/sort.xml index 00718fa3f9..0948a8f6d6 100644 --- a/reference/array/functions/sort.xml +++ b/reference/array/functions/sort.xml @@ -1,5 +1,5 @@ - + @@ -24,10 +24,10 @@ - + @@ -27,16 +27,18 @@ $b) ? -1 : 1; } -$a = array (4 => "four", 3 => "three", 20 => "twenty", 10 => "ten"); +$a = array(4 => "four", 3 => "three", 20 => "twenty", 10 => "ten"); -uksort ($a, "cmp"); +uksort($a, "cmp"); -while (list ($key, $value) = each ($a)) { +while (list($key, $value) = each($a)) { echo "$key: $value\n"; } ?> diff --git a/reference/array/functions/usort.xml b/reference/array/functions/usort.xml index 0862a6929b..32a862b617 100644 --- a/reference/array/functions/usort.xml +++ b/reference/array/functions/usort.xml @@ -1,5 +1,5 @@ - + @@ -43,16 +43,18 @@ @@ -96,7 +98,7 @@ $fruits[2]["fruit"] = "grapes"; usort($fruits, "cmp"); -while (list ($key, $value) = each ($fruits)) { +while (list($key, $value) = each($fruits)) { echo "\$fruits[$key]: " . $value["fruit"] . "\n"; } ?> @@ -140,7 +142,9 @@ class TestObj { { $al = strtolower($a->name); $bl = strtolower($b->name); - if ($al == $bl) return 0; + if ($al == $bl) { + return 0; + } return ($al > $bl) ? +1 : -1; } } @@ -149,10 +153,10 @@ $a[] = new TestObj("c"); $a[] = new TestObj("b"); $a[] = new TestObj("d"); -usort($a, array ("TestObj", "cmp_obj")); +usort($a, array("TestObj", "cmp_obj")); foreach ($a as $item) { - print $item->name."\n"; + print $item->name . "\n"; } ?> ]]>