php-doc-en/reference/strings/functions/strripos.xml
2007-12-02 01:08:18 +00:00

144 lines
3.8 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.13 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strripos">
<refnamediv>
<refname>strripos</refname>
<refpurpose>Find position of last occurrence of a case-insensitive string in a string</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>strripos</methodname>
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
<methodparam><type>string</type><parameter>needle</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>offset</parameter></methodparam>
</methodsynopsis>
<para>
Find position of last occurrence of a case-insensitive string in a string.
Unlike <function>strrpos</function>, <function>strripos</function> is
case-insensitive.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>haystack</parameter></term>
<listitem>
<para>
The string to search in
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>needle</parameter></term>
<listitem>
<para>
Note that the <parameter>needle</parameter> may be a string of one or
more characters.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>offset</parameter></term>
<listitem>
<para>
The <parameter>offset</parameter> parameter may be specified to begin
searching an arbitrary number of characters into the string.
</para>
<para>
Negative offset values will start the search at
<parameter>offset</parameter> characters from the
<emphasis>start</emphasis> of the string.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the numerical position of the last occurence of
<parameter>needle</parameter>. Also note that string positions start at 0,
and not 1.
</para>
<para>
If <parameter>needle</parameter> is not found, &false; is returned.
</para>
&return.falseproblem;
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>A simple <function>strripos</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$haystack = 'ababcd';
$needle = 'aB';
$pos = strripos($haystack, $needle);
if ($pos === false) {
echo "Sorry, we did not find ($needle) in ($haystack)";
} else {
echo "Congratulations!\n";
echo "We found the last ($needle) in ($haystack) at position ($pos)";
}
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Congratulations!
We found the last (aB) in (ababcd) at position (2)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>strpos</function></member>
<member><function>stripos</function></member>
<member><function>strrchr</function></member>
<member><function>substr</function></member>
<member><function>stristr</function></member>
<member><function>strstr</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
-->