php-doc-en/reference/strings/functions/strripos.xml
2003-12-15 16:55:22 +00:00

100 lines
2.8 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<refentry id="function.strripos">
<refnamediv>
<refname>strripos</refname>
<refpurpose>
Find position of last occurrence of a case-insensitive string in a string
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<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>
Returns the numeric position of the last occurrence of
<parameter>needle</parameter> in the
<parameter>haystack</parameter> string. Unlike
<function>strrpos</function>, <function>strripos</function> is
case-insensitive. Also note that string positions start at 0, and not
1.
</para>
<para>
Note that the <parameter>needle</parameter> may be a string of one or
more characters.
</para>
<para>
If <parameter>needle</parameter> is not found, &false; is returned.
</para>
&return.falseproblem;
<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>
<para>
Outputs:
</para>
<screen>
<![CDATA[
Congratulations!
We found the last (aB) in (ababcd) at position (2)
]]>
</screen>
</example>
</para>
<simpara>
<parameter>offset</parameter> may be specified to begin searching an
arbitrary number of characters into the string. Negative values will
stop searching at an arbitrary point prior to the end of the string.
</simpara>
<para>
See also <function>strrpos</function>,
<function>strrchr</function>,
<function>substr</function>, <function>stripos</function> and
<function>stristr</function>.
</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
-->