php-doc-en/reference/spl/splfixedarray/setsize.xml
2014-09-05 07:44:07 +00:00

104 lines
2.6 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="splfixedarray.setsize" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>SplFixedArray::setSize</refname>
<refpurpose>Change the size of an array</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>int</type><methodname>SplFixedArray::setSize</methodname>
<methodparam><type>int</type><parameter>size</parameter></methodparam>
</methodsynopsis>
<para>
Change the size of an array to the new size of <parameter>size</parameter>. If
<parameter>size</parameter> is less than the current array size, any values after the new size
will be discarded. If <parameter>size</parameter> is greater than the current array size, the
array will be padded with &null; values.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
The new array size. This should be a value between <literal>0</literal> and <constant>PHP_INT_MAX</constant>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.void;
</para>
</refsect1>
<refsect1 role="errors"><!-- {{{ -->
&reftitle.errors;
<para>
Throws <classname>InvalidArgumentException</classname> when <parameter>size</parameter> is less than zero.
</para>
<para>
Raises <constant>E_WARNING</constant> when <parameter>size</parameter> cannot be used as a number.
</para>
</refsect1><!-- }}} -->
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>SplFixedArray::setSize</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$array = new SplFixedArray(5);
echo $array->getSize()."\n";
$array->setSize(10);
echo $array->getSize()."\n";
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
5
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:"~/.phpdoc/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
-->