1
0
mirror of https://github.com/php/doc-uk.git synced 2026-03-24 23:22:14 +01:00
Files
George Peter Banyard 6114fd72df Small updated to Ukranian doc.
git-svn-id: https://svn.php.net/repository/phpdoc/uk/trunk@347636 c90b9560-bf6c-de11-be94-00142212c4b1
2019-06-22 03:18:16 +00:00

261 lines
7.5 KiB
XML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 0fe00e3574f5267948a29692e8daddaaeb275cee Maintainer: iSensetivity Status: ready -->
<!-- Reviewed: no -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.explode">
<refnamediv>
<refname>explode</refname>
<refpurpose>Розбиває рядок на підрядки</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>explode</methodname>
<methodparam><type>string</type><parameter>delimiter</parameter></methodparam>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>limit</parameter><initializer>PHP_INT_MAX</initializer></methodparam>
</methodsynopsis>
<para>
Повертає масив рядків, кожен з яких є підрядком
рядка <parameter>string</parameter>, який був поділений за допомогою
роздільника <parameter>delimiter</parameter>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>delimiter</parameter></term>
<listitem>
<para>
Роздільник.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
Вхідний рядок.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>limit</parameter></term>
<listitem>
<para>
Якщо параметр <parameter>limit</parameter> встановлений і мість додатнє число,
вихідний масив міститиме максимум <parameter>limit</parameter>
елементів. А останній елемент міститиме залишок рядка <parameter>string</parameter>.
</para>
<para>
Якщо параметр <parameter>limit</parameter> містить від'ємне число, повернуться всі елементи
окрім останніх -<parameter>limit</parameter>.
</para>
<para>
Якщо параметр <parameter>limit</parameter> дорівнює нулю, то він розцінюється як 1.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<note>
<para>
На відміну від <function>implode</function>, яка з історичних причин може приймати
параметри у будь-якому порядку, для
<function>explode</function> це недопустимо. Ви повинні переконатися, що аргумент
<parameter>delimiter</parameter> знаходиться перед аргументом
<parameter>string</parameter>.
</para>
</note>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Повертає масив (<type>array</type>) підрядків (<type>string</type>)
створених шляхом поділу <parameter>string</parameter>
на кордонах, заданих параметром <parameter>delimiter</parameter>.
</para>
<para>
Якщо <parameter>delimiter</parameter> є пустим рядком <type>string</type> (""),
<function>explode</function> поверне &false;.
Якщо <parameter>delimiter</parameter> містить значення, якого немає
в <parameter>string</parameter> а також коли парамерт <parameter>limit</parameter>
містить від'ємне значення - повертається порожній масив <type>array</type>.
В інакшому випадку повертається масив <type>array</type>, який
містить оригінальний рядок <parameter>string</parameter>.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.1.0</entry>
<entry>
Додано підтримку від'ємного значення параметра <parameter>limit</parameter>
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Використання <function>explode</function></title>
<programlisting role="php">
<![CDATA[
<?php
// Приклад 1
$pizza = "частина1 частина2 частина3 частина4 частина5 частина6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // частина1
echo $pieces[1]; // частина2
// Приклад 2
$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
echo $user; // foo
echo $pass; // *
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title><function>explode</function> Повернення результату</title>
<programlisting role="php">
<![CDATA[
<?php
/*
Рядок, який не містить роздільника,
просто поверне масив з одним значенням оригінального рядка.
*/
$input1 = "Привіт";
$input2 = "Привіт, народе!";
$input3 = ',';
var_dump( explode( ',', $input1 ) );
var_dump( explode( ',', $input2 ) );
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
array(1)
(
[0] => string(6) "Привіт"
)
array(2)
(
[0] => string(6) "Привіт"
[1] => string(8) " народе!"
)
array(2)
(
[0] => string(0) ""
[1] => string(0) ""
)
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Використання <parameter>limit</parameter></title>
<programlisting role="php">
<![CDATA[
<?php
$str = 'один|два|три|чотири';
// додатній ліміт
print_r(explode('|', $str, 2));
// від'ємний ліміт (з версії PHP 5.1)
print_r(explode('|', $str, -1));
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[0] => один
[1] => два|три|чотири
)
Array
(
[0] => один
[1] => два
[2] => три
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
&note.bin-safe;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>preg_split</function></member>
<member><function>str_split</function></member>
<member><function>mb_split</function></member>
<member><function>str_word_count</function></member>
<member><function>strtok</function></member>
<member><function>implode</function></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:"~/.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
-->