cvs: phpdoc /en/reference/spl arrayobject.xml /en/reference/spl/arrayobject asort.xml exchangearray.xml getarraycopy.xml getflags.xml
getiteratorclass.xml ksort.xml natcasesort.xml natsort.xml setflags.xml setiteratorclass.xml uasort.xml uksort.xml

From: Date: Sat, 27 Jun 2009 10:16:12 +0000
Subject: cvs: phpdoc /en/reference/spl arrayobject.xml /en/reference/spl/arrayobject asort.xml exchangearray.xml getarraycopy.xml getflags.xml
getiteratorclass.xml ksort.xml natcasesort.xml natsort.xml setflags.xml setiteratorclass.xml uasort.xml uksort.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-4254@lists.php.net to get a copy of this message
kalle Sat Jun 27 10:16:12 2009 UTC Added files: /phpdoc/en/reference/spl/arrayobject asort.xml exchangearray.xml getarraycopy.xml getflags.xml getiteratorclass.xml ksort.xml natcasesort.xml natsort.xml setflags.xml setiteratorclass.xml uasort.xml uksort.xml Modified files: /phpdoc/en/reference/spl arrayobject.xml Log: Lots of missing arrayobject documentation - contributed by Joris van de Sande <joris.devplace@gmail.com> # ArrayObject is still not 100% documented, this commit # only adds msising methods

http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject.xml?r1=1.4&r2=1.5&diff_format=u Index: phpdoc/en/reference/spl/arrayobject.xml diff -u phpdoc/en/reference/spl/arrayobject.xml:1.4 phpdoc/en/reference/spl/arrayobject.xml:1.5 --- phpdoc/en/reference/spl/arrayobject.xml:1.4 Sat Aug 23 14:09:14 2008 +++ phpdoc/en/reference/spl/arrayobject.xml Sat Jun 27 10:16:12 2009 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <phpdoc:classref xmlns:phpdoc="http://php.net/ns/phpdoc" xml:id="class.arrayobject" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"> <title>The ArrayObject class</title> <titleabbrev>ArrayObject</titleabbrev> @@ -10,7 +10,7 @@ <section xml:id="arrayobject.intro"> &reftitle.intro; <para> - ... + This class allows objects to work as arrays. </para> </section> <!-- }}} --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/asort.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/asort.xml +++ phpdoc/en/reference/spl/arrayobject/asort.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.asort" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::asort</refname> <refpurpose>Sort the entries by value</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>ArrayObject::asort</methodname> <void/> </methodsynopsis> <para> Sorts the entries such that the keys maintain their correlation with the entries they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; &no.function.parameters; </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.void; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::asort</function> example</title> <programlisting role="php"> <![CDATA[ <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); $fruitArrayObject = new ArrayObject($fruits); $fruitArrayObject->asort(); foreach ($fruitArrayObject as $key => $val) { echo "$key = $val\n"; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ c = apple b = banana d = lemon a = orange ]]> </screen> <para> The fruits have been sorted in alphabetical order, and the key associated with each entry has been maintained. </para> </example> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/exchangearray.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/exchangearray.xml +++ phpdoc/en/reference/spl/arrayobject/exchangearray.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.exchangearray" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::exchangeArray</refname> <refpurpose>Exchange the array for another one.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>ArrayObject::exchangeArray</methodname> <methodparam><type>mixed</type><parameter>input</parameter></methodparam> </methodsynopsis> <para> Exchange the current <type>array</type> with another <type>array</type> or <type>object</type>. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>input</parameter></term> <listitem> <para> The new <type>array</type> or <type>object</type> to exchange with the current array. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns the old <type>array</type>. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::exchangeArray</function> example</title> <programlisting role="php"> <![CDATA[ <?php // Array of available fruits $fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10); // Array of locations in Europe $locations = array('Amsterdam', 'Paris', 'London'); $fruitsArrayObject = new ArrayObject($fruits); // Now exchange fruits for locations $old = $fruitsArrayObject->exchangeArray($locations); print_r($old); print_r($fruitsArrayObject); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [lemons] => 1 [oranges] => 4 [bananas] => 5 [apples] => 10 ) ArrayObject Object ( [0] => Amsterdam [1] => Paris [2] => London ) ]]> </screen> </example> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/getarraycopy.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/getarraycopy.xml +++ phpdoc/en/reference/spl/arrayobject/getarraycopy.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.getarraycopy" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::getArrayCopy</refname> <refpurpose>Creates a copy of the ArrayObject.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>ArrayObject::getArrayCopy</methodname> <void/> </methodsynopsis> <para> Exports the <classname>ArrayObject</classname> to an array. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; &no.function.parameters; </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns a copy of the array. When the <classname>ArrayObject</classname> refers to an object an array of the public properties of that object will be returned. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::getArrayCopy</function> example</title> <programlisting role="php"> <![CDATA[ <?php // Array of available fruits $fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10); $fruitsArrayObject = new ArrayObject($fruits); $fruitsArrayObject['pears'] = 4; // create a copy of the array $copy = $fruitsArrayObject->getArrayCopy(); print_r($copy); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [lemons] => 1 [oranges] => 4 [bananas] => 5 [apples] => 10 [pears] => 4 ) ]]> </screen> </example> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/getflags.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/getflags.xml +++ phpdoc/en/reference/spl/arrayobject/getflags.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.getflags" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::getFlags</refname> <refpurpose>Gets the behavior flags.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>ArrayObject::getFlags</methodname> <void/> </methodsynopsis> <para> Gets the behavior flags of the <classname>ArrayObject</classname>. See the <link linkend="arrayobject.setflags">ArrayObject::setFlags</link> method for a list of the available flags. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; &no.function.parameters; </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns the behavior flags of the ArrayObject. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::getFlags</function> example</title> <programlisting role="php"> <![CDATA[ <?php // Array of available fruits $fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10); $fruitsArrayObject = new ArrayObject($fruits); // Get the current flags $flags = $fruitsArrayObject->getFlags(); var_dump($flags); // Set new flags $fruitsArrayObject->setFlags(ArrayObject::ARRAY_AS_PROPS); // Get the new flags $flags = $fruitsArrayObject->getFlags(); var_dump($flags); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ int(0) int(2) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member>The <link linkend="arrayobject.setflags">ArrayObject::setFlags</link> method</member> </simplelist> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/getiteratorclass.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/getiteratorclass.xml +++ phpdoc/en/reference/spl/arrayobject/getiteratorclass.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.getiteratorclass" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::getIteratorClass</refname> <refpurpose>Gets the iterator classname for the ArrayObject.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>ArrayObject::getIteratorClass</methodname> <void/> </methodsynopsis> <para> Gets the classname of the array iterator that is used by <link linkend="arrayobject.getiterator">ArrayObject::getIterator()</link>. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; &no.function.parameters; </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns the iterator class name that is used to iterate over this object. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::getIteratorClass</function> example</title> <programlisting role="php"> <![CDATA[ <?php // Custom ArrayIterator (inherits from ArrayIterator) class MyArrayIterator extends ArrayIterator { // custom implementation } // Array of available fruits $fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10); $fruitsArrayObject = new ArrayObject($fruits); // Get the current class name $className = $fruitsArrayObject->getIteratorClass(); var_dump($className); // Set new classname $fruitsArrayObject->setIteratorClass('MyArrayIterator'); // Get the new iterator classname $className = $fruitsArrayObject->getIteratorClass(); var_dump($className); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(13) "ArrayIterator" string(15) "MyArrayIterator" ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member>The <link linkend="arrayobject.setiteratorclass">ArrayObject::setIteratorClass</link> method</member> </simplelist> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/ksort.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/ksort.xml +++ phpdoc/en/reference/spl/arrayobject/ksort.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.ksort" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::ksort</refname> <refpurpose>Sort the entries by key</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>ArrayObject::ksort</methodname> <void/> </methodsynopsis> <para> Sorts the entries by key, maintaining key to entry correlations. This is useful mainly for associative arrays. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; &no.function.parameters; </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.void; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::ksort</function> example</title> <programlisting role="php"> <![CDATA[ <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); $fruitArrayObject = new ArrayObject($fruits); $fruitArrayObject->ksort(); foreach ($fruitArrayObject as $key => $val) { echo "$key = $val\n"; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ a = orange b = banana c = apple d = lemon ]]> </screen> </example> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/natcasesort.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/natcasesort.xml +++ phpdoc/en/reference/spl/arrayobject/natcasesort.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.natcasesort" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>ArrayObject::natcasesort</refname> <refpurpose>Sort an array using a case insensitive "natural order" algorithm</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>ArrayObject::natcasesort</methodname> <void/> </methodsynopsis> <para> This method is a case insensitive version of <link linkend="arrayobject.natsort">ArrayObject::natsort</link>. </para> <para> This method implements a sort algorithm that orders alphanumeric strings in the way a human being would while maintaining key/value associations. This is described as a "natural ordering". </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; &no.function.parameters; </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.void; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::natcasesort</function> example</title> <programlisting role="php"> <![CDATA[ <?php $array = array('IMG0.png', 'img12.png', 'img10.png', 'img2.png', 'img1.png', 'IMG3.png'); $arr1 = new ArrayObject($array); $arr2 = clone $arr1; $arr1->asort(); echo "Standard sorting\n"; print_r($arr1); $arr2->natcasesort(); echo "\nNatural order sorting (case-insensitive)\n"; print_r($arr2); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Standard sorting ArrayObject Object ( [0] => IMG0.png [5] => IMG3.png [4] => img1.png [2] => img10.png [1] => img12.png [3] => img2.png ) Natural order sorting (case-insensitive) ArrayObject Object ( [0] => IMG0.png [4] => img1.png [3] => img2.png [5] => IMG3.png [2] => img10.png [1] => img12.png ) ]]> </screen> <para> For more information see: Martin Pool's <link xlink:href="&url.strnatcmp;">Natural Order String Comparison</link> page. </para> </example> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/natsort.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/natsort.xml +++ phpdoc/en/reference/spl/arrayobject/natsort.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.natsort" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>ArrayObject::natsort</refname> <refpurpose>Sort entries using a "natural order" algorithm</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>ArrayObject::natsort</methodname> <void/> </methodsynopsis> <para> This method implements a sort algorithm that orders alphanumeric strings in the way a human being would while maintaining key/value associations. This is described as a "natural ordering". An example of the difference between this algorithm and the regular computer string sorting algorithms (used in <link linkend="arrayobject.asort">ArrayObject::asort</link>) method can be seen in the example below. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; &no.function.parameters; </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.void; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::natsort</function> example</title> <programlisting role="php"> <![CDATA[ <?php $array = array("img12.png", "img10.png", "img2.png", "img1.png"); $arr1 = new ArrayObject($array); $arr2 = clone $arr1; $arr1->asort(); echo "Standard sorting\n"; print_r($arr1); $arr2->natsort(); echo "\nNatural order sorting\n"; print_r($arr2); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Standard sorting ArrayObject Object ( [3] => img1.png [1] => img10.png [0] => img12.png [2] => img2.png ) Natural order sorting ArrayObject Object ( [3] => img1.png [2] => img2.png [1] => img10.png [0] => img12.png ) ]]> </screen> <para> For more information see: Martin Pool's <link xlink:href="&url.strnatcmp;">Natural Order String Comparison</link> page. </para> </example> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/setflags.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/setflags.xml +++ phpdoc/en/reference/spl/arrayobject/setflags.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.setflags" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::setFlags</refname> <refpurpose>Sets the behavior flags.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>ArrayObject::setFlags</methodname> <methodparam><type>int</type><parameter>flags</parameter></methodparam> </methodsynopsis> <para> Set the flags that change the behavior of the ArrayObject. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>flags</parameter></term> <listitem> <para> The new ArrayObject behavior. It takes on either a bitmask, or named constants. Using named constants is strongly encouraged to ensure compatibility for future versions. </para> <para> The available behavior flags are listed below. <table> <title>ArrayObject behavior flags</title> <tgroup cols="2"> <thead> <row> <entry>value</entry> <entry>constant</entry> </row> </thead> <tbody> <row> <entry>1</entry> <entry> <constant>ArrayObject::STD_PROP_LIST</constant> </entry> </row> <row> <entry>2</entry> <entry> <constant>ArrayObject::ARRAY_AS_PROPS</constant> </entry> </row> </tbody> </tgroup> </table> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.void; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::setFlags</function> example</title> <programlisting role="php"> <![CDATA[ <?php // Array of available fruits $fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10); $fruitsArrayObject = new ArrayObject($fruits); // Try to use array key as property print_r($fruitsArrayObject->lemons); // Set the flag so that the array keys can be used as properties of the ArrayObject $fruitsArrayObject->setFlags(ArrayObject::ARRAY_AS_PROPS); // Try it again print_r($fruitsArrayObject->lemons); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ NULL int(1) ]]> </screen> </example> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/setiteratorclass.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/setiteratorclass.xml +++ phpdoc/en/reference/spl/arrayobject/setiteratorclass.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.setiteratorclass" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::setIteratorClass</refname> <refpurpose>Sets the iterator classname for the ArrayObject.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>ArrayObject::setIteratorClass</methodname> <methodparam><type>string</type><parameter>iterator_class</parameter></methodparam> </methodsynopsis> <para> Sets the classname of the array iterator that is used by <link linkend="arrayobject.getiterator">ArrayObject::getIterator()</link>. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>iterator_class</parameter></term> <listitem> <para> The classname of the array iterator to use when iterating over this object. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.void; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::setIteratorClass</function> example</title> <programlisting role="php"> <![CDATA[ <?php // Custom ArrayIterator (inherits from ArrayIterator) class MyArrayIterator extends ArrayIterator { // custom implementation } // Array of available fruits $fruits = array("lemons" => 1, "oranges" => 4, "bananas" => 5, "apples" => 10); $fruitsArrayObject = new ArrayObject($fruits); // Set the iterator classname to the newly $fruitsArrayObject->setIteratorClass('MyArrayIterator'); print_r($fruitsArrayObject->getIterator()); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ MyArrayIterator Object ( [lemons] => 1 [oranges] => 4 [bananas] => 5 [apples] => 10 ) ]]> </screen> </example> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/uasort.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/uasort.xml +++ phpdoc/en/reference/spl/arrayobject/uasort.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.uasort" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::uasort</refname> <refpurpose>Sort the entries with a user-defined comparison function and maintain key association</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>ArrayObject::uasort</methodname> <methodparam><type>callback</type><parameter>cmp_function</parameter></methodparam> </methodsynopsis> <para> This function sorts the entries such that keys maintain their correlation with the entry that they are associated with, using a user-defined comparison function. </para> <para> This is used mainly when sorting associative arrays where the actual element order is significant. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>cmp_function</parameter></term> <listitem> <para> Function <parameter>cmp_function</parameter> should accept two parameters which will be filled by pairs of entries. The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.void; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::uasort</function> example</title> <programlisting role="php"> <![CDATA[ <?php // Comparison function function cmp($a, $b) { if ($a == $b) { return 0; } return ($a < $b) ? -1 : 1; } // Array to be sorted $array = array('a' => 4, 'b' => 8, 'c' => -1, 'd' => -9, 'e' => 2, 'f' => 5, 'g' => 3, 'h' => -4); $arrayObject = new ArrayObject($array); print_r($arrayObject); // Sort and print the resulting array $arrayObject->uasort('cmp'); print_r($arrayObject); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Array ( [a] => 4 [b] => 8 [c] => -1 [d] => -9 [e] => 2 [f] => 5 [g] => 3 [h] => -4 ) Array ( [d] => -9 [h] => -4 [c] => -1 [e] => 2 [g] => 3 [a] => 4 [f] => 5 [b] => 8 ) ]]> </screen> </example> </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 --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/spl/arrayobject/uksort.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/spl/arrayobject/uksort.xml +++ phpdoc/en/reference/spl/arrayobject/uksort.xml <?xml version='1.0' encoding='iso-8859-1'?> <!-- $Revision: 1.1 $ --> <refentry xml:id="arrayobject.uksort" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>ArrayObject::uksort</refname> <refpurpose>Sort the entries by keys using a user-defined comparison function</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>ArrayObject::uksort</methodname> <methodparam><type>callback</type><parameter>cmp_function</parameter></methodparam> </methodsynopsis> <para> This function sorts the the keys of the entries using a user-supplied comparison function. The key to entry correlations will be maintained. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>cmp_function</parameter></term> <listitem> <para> The callback comparison function. </para> <para> Function <parameter>cmp_function</parameter> should accept two parameters which will be filled by pairs of entry keys. The comparison function must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.void; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>ArrayObject::uksort</function> example</title> <programlisting role="php"> <![CDATA[ <?php function cmp($a, $b) { $a = preg_replace('@^(a|an|the) @', '', $a); $b = preg_replace('@^(a|an|the) @', '', $b); return strcasecmp($a, $b); } $array = array("John" => 1, "the Earth" => 2, "an apple" => 3, "a banana" => 4); $arrayObject = new ArrayObject($array); $arrayObject->uksort('cmp'); foreach ($arrayObject as $key => $value) { echo "$key: $value\n"; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ an apple: 3 a banana: 4 the Earth: 2 John: 1 ]]> </screen> </example> </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 -->
« previous php.doc.cvs (#4254) next »