mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
fix for #11937. pointing out that unset() will not
cause a reindexing of an array when deleting a key. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@64875 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
19c18524d3
commit
7c88782195
1 changed files with 23 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.68 $ -->
|
||||
<!-- $Revision: 1.69 $ -->
|
||||
<chapter id="language.types">
|
||||
<title>Types</title>
|
||||
|
||||
|
@ -1167,11 +1167,33 @@ $arr[] = <replaceable>value</replaceable>;
|
|||
with arrays, see the <link linkend="ref.array">array-functions</link>
|
||||
section.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
The <function>unset</function> function allows unsetting keys of an
|
||||
array. Be aware that the array will NOT be reindexed.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
$a = array( 1 => 'one', 2 => 'two', 3 => 'three' );
|
||||
unset( $a[2] );
|
||||
/* will produce an array that would have been defined as
|
||||
$a = array( 1=>'one', 3=>'three');
|
||||
and NOT
|
||||
$a = array( 1 => 'one', 2 => 'three');
|
||||
*/
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
The <link linkend="control-structures.foreach">foreach</link>
|
||||
control structure exists specificly for arrays. It
|
||||
provides an easy way to traverse an array.
|
||||
</para>
|
||||
|
||||
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.types.array.donts">
|
||||
|
|
Loading…
Reference in a new issue