2002-05-12 08:19:28 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2004-08-03 10:24:06 +00:00
|
|
|
<!-- $Revision: 1.10 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<!-- splitted from ./en/functions/array.xml, last change in rev 1.2 -->
|
|
|
|
<refentry id="function.array-unshift">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>array_unshift</refname>
|
|
|
|
<refpurpose>
|
2003-12-26 18:42:02 +00:00
|
|
|
Prepend one or more elements to the beginning of an array
|
2002-04-15 00:12:54 +00:00
|
|
|
</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>int</type><methodname>array_unshift</methodname>
|
2004-08-03 10:24:06 +00:00
|
|
|
<methodparam><type>array</type><parameter>&array</parameter></methodparam>
|
2002-04-15 00:12:54 +00:00
|
|
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
2004-08-03 10:24:06 +00:00
|
|
|
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
|
2002-04-15 00:12:54 +00:00
|
|
|
</methodsynopsis>
|
|
|
|
<para>
|
|
|
|
<function>array_unshift</function> prepends passed elements to
|
|
|
|
the front of the <parameter>array</parameter>. Note that the list
|
|
|
|
of elements is prepended as a whole, so that the prepended
|
2002-06-17 23:48:37 +00:00
|
|
|
elements stay in the same order. All numerical array keys will be
|
|
|
|
modified to start counting from zero while literal keys won't be touched.
|
2002-04-15 00:12:54 +00:00
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Returns the new number of elements in the
|
|
|
|
<parameter>array</parameter>.
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title><function>array_unshift</function> example</title>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
2003-05-30 18:12:53 +00:00
|
|
|
<?php
|
2003-08-17 12:21:03 +00:00
|
|
|
$queue = array("orange", "banana");
|
|
|
|
array_unshift($queue, "apple", "raspberry");
|
2003-05-30 18:12:53 +00:00
|
|
|
?>
|
2002-04-15 00:12:54 +00:00
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
<para>
|
|
|
|
This would result in <varname>$queue</varname> having the
|
|
|
|
following elements:
|
2003-06-16 12:03:39 +00:00
|
|
|
</para>
|
|
|
|
<screen role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
|
|
|
Array
|
|
|
|
(
|
|
|
|
[0] => apple
|
|
|
|
[1] => raspberry
|
|
|
|
[2] => orange
|
|
|
|
[3] => banana
|
|
|
|
)
|
|
|
|
]]>
|
2003-06-16 12:03:39 +00:00
|
|
|
</screen>
|
2002-04-15 00:12:54 +00:00
|
|
|
</example>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
See also <function>array_shift</function>,
|
|
|
|
<function>array_push</function>, and
|
|
|
|
<function>array_pop</function>.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
|
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|