Files
doc-fr/reference/strings/functions/strstr.xml
Damien Seguy 97efa88e24 synch with en
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@274154 c90b9560-bf6c-de11-be94-00142212c4b1
2009-01-22 05:23:08 +00:00

170 lines
4.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.19 $ -->
<!-- EN-Revision: 1.19 Maintainer: yannick Status: ready -->
<!-- Reviewed: yes -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strstr">
<refnamediv>
<refname>strstr</refname>
<refpurpose>Trouve la première occurrence dans une chaîne</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>strstr</methodname>
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
<methodparam><type>mixed</type><parameter>needle</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>before_needle</parameter><initializer>false</initializer></methodparam>
</methodsynopsis>
<para>
Retourne une sous-chaîne de <parameter>haystack</parameter>,
allant de la première occurrence de <parameter>needle</parameter> jusqu'à la fin
de la chaîne.
</para>
<note>
<para>
<function>strstr</function> est sensible à la casse. Pour une fonctionnalité
identique, mais insensible à la casse, reportez-vous à
<function>stristr</function>.
</para>
</note>
<note>
<para>
Si vous voulez juste déterminer si un <parameter>needle</parameter> particulier
se trouve dans la chaîne <parameter>haystack</parameter>, utilisez la fonction
<function>strpos</function> qui est plus rapide et qui consomme moins de ressources.
</para>
</note>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>haystack</parameter></term>
<listitem>
<para>
La chaîne d'entrée.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>needle</parameter></term>
<listitem>
<para>
Si <parameter>needle</parameter> n'est pas une chaîne, elle
sera convertie en entier, et utilisée comme code ASCII du caractère
correspondant.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>before_needle</parameter></term>
<listitem>
<para>
Si vaut &true; (par défaut, vaut &false;), <function>strstr</function> retourne
la partie de <parameter>haystack</parameter> avant la première occurrence de
<parameter>needle</parameter>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Retourne la portion de la chaîne, ou &false; si <parameter>needle</parameter>
n'est pas trouvé.
</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.3.0</entry>
<entry>
Ajout du paramètre optionnel <parameter>before_needle</parameter>.
</entry>
</row>
<row>
<entry>4.3.0</entry>
<entry>
<function>strstr</function> est maintenant compatible avec les données binaires.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Exemple avec <function>strstr</function></title>
<programlisting role="php">
<![CDATA[
<?php
$email = 'name@example.com';
$domain = strstr($email, '@');
echo $domain; // Affiche : @example.com
$user = strstr($email, '@', true); // Depuis PHP 5.3.0
echo $user; // Affiche : name
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>preg_match</function></member>
<member><function>stristr</function></member>
<member><function>strpos</function></member>
<member><function>strrchr</function></member>
<member><function>substr</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:"../../../../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
-->