mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-27 10:22:07 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@172818 c90b9560-bf6c-de11-be94-00142212c4b1
128 lines
3.0 KiB
XML
128 lines
3.0 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.7 $ -->
|
|
<!-- EN-Revision: 1.3 Maintainer: didou Status: ready -->
|
|
<refentry id="function.str-split">
|
|
<refnamediv>
|
|
<refname>str_split</refname>
|
|
<refpurpose>
|
|
Convertit une chaîne de caractères en tableau
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>array</type><methodname>str_split</methodname>
|
|
<methodparam><type>string</type><parameter>string</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>split_length</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Convertit une chaîne de caractères en tableau. Si le paramètre optionnel
|
|
<parameter>split_length</parameter> est spécifié, le tableau retourné
|
|
sera découpé en sous-parties, chacune de taille
|
|
<parameter>split_length</parameter>, sinon, chaque sous-partie aura la
|
|
taille d'un caractère.
|
|
</para>
|
|
<para>
|
|
Cette fonction retourne &false; si <parameter>split_length</parameter>
|
|
est inférieur à 1. Si la longueur de <parameter>split_length</parameter>
|
|
est supérieure à celle de <parameter>string</parameter>, la chaîne
|
|
entière est retournée dans le premier (et seul) élément du tableau.
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemples d'utilisation de <function>str_split</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$str = "Salut Dave";
|
|
|
|
$arr1 = str_split($str);
|
|
$arr2 = str_split($str, 3);
|
|
|
|
print_r($arr1);
|
|
print_r($arr2);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[0] => S
|
|
[1] => a
|
|
[2] => l
|
|
[3] => u
|
|
[4] => t
|
|
[5] =>
|
|
[6] => D
|
|
[7] => a
|
|
[8] => v
|
|
[9] => e
|
|
)
|
|
|
|
Array
|
|
(
|
|
[0] => Sal
|
|
[1] => ut
|
|
[2] => Dav
|
|
[3] => e
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemples liés à <function>str_split</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$str = "Salut Dave";
|
|
|
|
print $str{0}; // S
|
|
print $str{8}; // v
|
|
|
|
// Crée : array('S','a','l','u','t',' ','D','a','v','e')
|
|
$arr1 = preg_split('//', $str, -1, PREG_SPLIT_NO_EMPTY);
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Voir aussi <function>chunk_split</function>,
|
|
<function>preg_split</function>,
|
|
<function>split</function>,
|
|
<function>count_chars</function>,
|
|
<function>str_word_count</function> et
|
|
<link linkend="control-structures.for">for</link>.
|
|
</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
|
|
-->
|