cvs: /phpdoc/functions array.sgml

From: Date: Fri, 16 Jul 1999 13:05:14 +0000
Subject: cvs: /phpdoc/functions array.sgml
Groups: php.dev 
Request: Send a blank email to php-dev+get-8593@lists.php.net to get a copy of this message
andrey Fri Jul 16 13:05:14 1999 EDT Modified files: /phpdoc/functions array.sgml Log: Time to document those array functions. This batch has docs for array_push/array_pop/array_unshift/array_shift. Index: phpdoc/functions/array.sgml diff -u phpdoc/functions/array.sgml:1.4 phpdoc/functions/array.sgml:1.5 --- phpdoc/functions/array.sgml:1.4 Sun Jun 27 22:07:12 1999 +++ phpdoc/functions/array.sgml Fri Jul 16 13:05:14 1999 @@ -1,4 +1,3 @@ - <reference id="ref.array"> <title>Array functions</title> <titleabbrev>Arrays</titleabbrev> @@ -49,6 +48,161 @@ </refsect1> </refentry> + <refentry id="function.array-push"> + <refnamediv> + <refname>array_push</refname> + <refpurpose>Push one or more elements onto the end of array</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>int <function>array_push</function></funcdef> + <paramdef>array <parameter>array</parameter></paramdef> + <paramdef>mixed <parameter>var</parameter></paramdef> + <paramdef><parameter>...</parameter></paramdef> + </funcsynopsis> + + <para> + <function>array_push</function> treats + <parameter>array</parameter> as a stack, and pushes the passed + variables onto the end of <parameter>array</parameter>. The + length of <parameter>array</parameter> increases by the number of + variables pushed. Has the same effect as: + <programlisting> +$array[] = $var; + </programlisting> + repeated for each <parameter>var</parameter>. + + <para> + Returns the new number of elements in the array. + + <para> + <example> + <title><function>array_push</function> example</title> + <programlisting> +$stack = array(1, 2); +array_push($stack, "+", 3); + </programlisting> + </example> + This example would result in $stack having 4 elements: 1, 2, "+", and 3. + + <para> + See also <function>array_pop</function>, + <function>array_shift</function>, and + <function>array_unshift</function>. + </refsect1> + </refentry> + + <refentry id="function.array-pop"> + <refnamediv> + <refname>array_pop</refname> + <refpurpose>Pop the element off the end of array</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>mixed <function>array_pop</function></funcdef> + <paramdef>array <parameter>array</parameter></paramdef> + </funcsynopsis> + + <para> + <function>array_pop</function> pops and returns the last value of + the <parameter>array</parameter>, shortening the + <parameter>array</parameter> by one element. + + <para> + <example> + <title><function>array_pop</function> example</title> + <programlisting> +$stack = array("orange", "apple", "raspberry"); +$fruit = array_pop($stack); + </programlisting> + After this, $stack has only 2 elements: "orange" and "apple", + and $fruit has "raspberry". + </example> + + <para> + See also <function>array_push</function>, + <function>array_shift</function>, and + <function>array_unshift</function>. + </refsect1> + </refentry> + + <refentry id="function.array-unshift"> + <refnamediv> + <refname>array_unshift</refname> + <refpurpose>Push one or more elements + onto the beginning of array</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcprototype> + <funcdef>int <function>array_unshift</function></funcdef> + <paramdef>array <parameter>array</parameter></paramdef> + <paramdef>mixed <parameter>var</parameter></paramdef> + <paramdef><parameter>...</parameter></paramdef> + </funcprototype> + </funcsynopsis> + + <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 + elements stay in the same order. + + <para> + Returns the new number of elements in the + <parameter>array</parameter>. + + <para> + <example> + <title><function>array_unshift</function> example</title> + <programlisting> +$queue = array("p1", "p3"); +array_unshift($queue, "p4", "p5", "p6"); + </programlisting> + </example> + This would result in $queue having 5 elements: "p4", "p5", "p6", + "p1", and "p3". + + <para> + See also <function>array_shift</function>, + <function>array_push</function>, and + <function>array_pop</function>. + </refsect1> + </refentry> + + <refentry id="function.array-shift"> + <refnamediv> + <refname>array_shift</refname> + <refpurpose>Pop an element of the beginning of array</refpurpose> + </refnamediv> + <refsect1> + <title>Description</title> + <funcsynopsis> + <funcdef>mixed <function>array_shift</function></funcdef> + <paramdef>array <parameter>array</parameter></paramdef> + </funcsynopsis> + + <para> + <function>array_shift</function> shifts the first value of the + <parameter>array</parameter> off and returns it, shortening the + <parameter>array</parameter> by one element and moving everything + down. + + <para> + <example> + <title><function>array_shift</function> example</title> + <programlisting> +$args = array("-v", "-f"); +$opt = array_shift($args); + </programlisting> + </example> + This would result in $args having one element "-f" left, and $opt + being "-v". + </refsect1> + </refentry> <refentry id="function.array-walk"> <refnamediv>

« previous php.dev (#8593) next »