mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Make array_splice() example clearer
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@342773 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
daa3a5eedc
commit
f9f9a44875
1 changed files with 11 additions and 0 deletions
|
@ -150,16 +150,27 @@ array_splice($input, 3, 0, "purple");
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// append two elements to $input
|
||||
array_push($input, $x, $y);
|
||||
array_splice($input, count($input), 0, array($x, $y));
|
||||
|
||||
// remove the last element of $input
|
||||
array_pop($input);
|
||||
array_splice($input, -1);
|
||||
|
||||
// remove the first element of $input
|
||||
array_shift($input);
|
||||
array_splice($input, 0, 1);
|
||||
|
||||
// insert an element at the start of $input
|
||||
array_unshift($input, $x, $y);
|
||||
array_splice($input, 0, 0, array($x, $y));
|
||||
|
||||
// replace the value in $input at index $x
|
||||
$input[$x] = $y; // for arrays where key equals offset
|
||||
array_splice($input, $x, 1, $y);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
Loading…
Reference in a new issue