mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Made the array_splice example compliant cut/paste.
Added an (obvious?) detail to array_diff(). git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@48774 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
2fe7f70489
commit
c0d39a4764
1 changed files with 16 additions and 8 deletions
|
@ -184,15 +184,16 @@ array_count_values ($array); // returns array (1=>2, "hello"=>2, "world"=&
|
|||
<example>
|
||||
<title><function>Array_diff</function> example</title>
|
||||
<programlisting role="php">
|
||||
$array1 = array ("a" => "green", "red", "blue");
|
||||
$array1 = array ("a" => "green", "red", "blue", "red");
|
||||
$array2 = array ("b" => "green", "yellow", "red");
|
||||
$result = array_diff ($array1, $array2);
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
This makes <varname>$result</varname> have <literal>array
|
||||
("blue");</literal>
|
||||
This makes <varname>$result</varname> have
|
||||
<literal>array ("blue");</literal>. Multiple occurences in
|
||||
$array1 are all treated the same way.
|
||||
</para>
|
||||
<para>
|
||||
See also <function>array_intersect</function>.
|
||||
|
@ -1295,14 +1296,21 @@ $a[$x] = $y array_splice ($input, $x, 1, $y)
|
|||
<title><function>Array_splice</function> examples</title>
|
||||
<programlisting role="php">
|
||||
$input = array ("red", "green", "blue", "yellow");
|
||||
array_splice ($input, 2);
|
||||
// $input is now array ("red", "green")
|
||||
|
||||
array_splice ($input, 2); // $input is now array ("red", "green")
|
||||
array_splice ($input, 1, -1); // $input is now array ("red", "yellow")
|
||||
$input = array ("red", "green", "blue", "yellow");
|
||||
array_splice ($input, 1, -1);
|
||||
// $input is now array ("red", "yellow")
|
||||
|
||||
$input = array ("red", "green", "blue", "yellow");
|
||||
array_splice ($input, 1, count($input), "orange");
|
||||
// $input is now array ("red", "orange")
|
||||
// $input is now array ("red", "orange")
|
||||
|
||||
$input = array ("red", "green", "blue", "yellow");
|
||||
array_splice ($input, -1, 1, array("black", "maroon"));
|
||||
// $input is now array ("red", "green",
|
||||
// "blue", "black", "maroon")
|
||||
// $input is now array ("red", "green",
|
||||
// "blue", "black", "maroon")
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
|
Loading…
Reference in a new issue