Files
doc-fr/reference/strings/functions/stristr.xml
2021-09-24 04:13:47 +01:00

190 lines
4.9 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 8cdc6621f9826d04abc3e50438c010804d7e8683 Maintainer: yannick Status: ready -->
<!-- Reviewed: yes -->
<refentry xml:id="function.stristr" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>stristr</refname>
<refpurpose>Version insensible à la casse de <function>strstr</function></refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>string</type><type>false</type></type><methodname>stristr</methodname>
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
<methodparam><type>string</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>
(incluse) jusqu'à la fin de la chaîne.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>haystack</parameter></term>
<listitem>
<para>
La chaîne dans laquelle on doit chercher.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>needle</parameter></term>
<listitem>
&strings.parameter.needle.non-string;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>before_needle</parameter></term>
<listitem>
<para>
Si vaut &true;, <function>stristr</function>
retourne la partie de <parameter>haystack</parameter> avant la première
occurrence de <parameter>needle</parameter> (<parameter>needle</parameter>
exclus).
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
<para>
<parameter>needle</parameter> et <parameter>haystack</parameter>
sont traitées sans tenir compte de la casse.
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Retourne la partie de la chaîne correspondante. Si
<parameter>needle</parameter> n'est pas trouvé, la fonction
retourne &false;.
</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>8.0.0</entry>
<entry>
Passing an &integer; as <parameter>needle</parameter> is no longer supported.
</entry>
</row>
<row>
<entry>7.3.0</entry>
<entry>
Passer un &integer; comme <parameter>before_needle</parameter> a été
rendu obsolète.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Exemple avec <function>stristr</function></title>
<programlisting role="php">
<![CDATA[
<?php
$email = 'USER@EXAMPLE.com';
echo stristr($email, 'e'); // Affiche ER@EXAMPLE.com
echo stristr($email, 'e', true); // Affiche US
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Teste si une chaîne de caractères est trouvée ou pas</title>
<programlisting role="php">
<![CDATA[
<?php
$string = 'Hello World!';
if(stristr($string, 'terre') === FALSE) {
echo '"terre" non trouvé dans la chaîne de caractères';
}
// affiche : "terre" non trouvé dans la chaîne de caractères
?>
]]>
</programlisting>
</example>
</para>
<para>
<example>
<title>Utilisation d'une "chaîne de caractères" en chiffre</title>
<programlisting role="php">
<![CDATA[
<?php
$string = 'POMME';
echo stristr($string, 112); // 112 = p minuscule
// Affiche : POMME
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
&note.bin-safe;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>strstr</function></member>
<member><function>strrchr</function></member>
<member><function>stripos</function></member>
<member><function>strpbrk</function></member>
<member><function>preg_match</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
-->