mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-24 07:02:09 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/pt_BR/trunk@248653 c90b9560-bf6c-de11-be94-00142212c4b1
103 lines
3.3 KiB
XML
103 lines
3.3 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- EN-Revision: 1.15 Maintainer: felipe Status: ready --><!-- CREDITS: lucasr -->
|
|
<refentry xml:id="function.array-slice" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>array_slice</refname>
|
|
<refpurpose>Extrai uma parcela de um array</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descrição</title>
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>array_slice</methodname>
|
|
<methodparam><type>array</type><parameter>array</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>length</parameter></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>preserve_keys</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>array_slice</function> retorna a sequência de elementos
|
|
de <parameter>array</parameter> especificada pelos parâmetros
|
|
<parameter>offset</parameter> e <parameter>length</parameter>.
|
|
</para>
|
|
<para>
|
|
Se <parameter>offset</parameter> for não negativo, a sequência
|
|
começará do início de <parameter>array</parameter>. Se
|
|
<parameter>offset</parameter> for negativo, a sequência
|
|
começará dessa distância do final de <parameter>array</parameter>.
|
|
</para>
|
|
<para>
|
|
Se <parameter>length</parameter> for especificado e positivo, então
|
|
a sequência terá essa quantidade de elementos. Se
|
|
<parameter>length</parameter> for especificado e negativo então
|
|
a sequência pará dessa quantidade elementos a partir do final do
|
|
array. Se for omitido, então a sequência terá todos os elementos
|
|
a partir de <parameter>offset</parameter> até o final de
|
|
<parameter>array</parameter>.
|
|
</para>
|
|
<para>
|
|
Note que <function>array_slice</function> irá reordenar e resetar as chaves
|
|
numéricas por padrão. Desde o PHP 5.0.2, você pode mudar esse comportamento
|
|
definindo <parameter>preserve_keys</parameter> como &true;.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemplos de <function>array_slice</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$input = array("a", "b", "c", "d", "e");
|
|
|
|
$output = array_slice($input, 2); // retorna "c", "d", e "e"
|
|
$output = array_slice($input, 2, -1); // retorna "c", "d"
|
|
$output = array_slice($input, -2, 1); // retorna "d"
|
|
$output = array_slice($input, 0, 3); // retorna "a", "b", e "c"
|
|
// Npote as diferenças nas chaves das arrays
|
|
print_r(array_slice($input, 2, -1));
|
|
print_r(array_slice($input, 2, -1, true));
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[0] => c
|
|
[1] => d
|
|
)
|
|
Array
|
|
(
|
|
[2] => c
|
|
[3] => d
|
|
}
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Veja também <function>array_splice</function> e <function>unset</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
|
|
-->
|