php-doc-en/reference/strings/functions/strrpos.xml
Derick Rethans 323ef98520 - Note reordering and unrolling
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@131848 c90b9560-bf6c-de11-be94-00142212c4b1
2003-06-16 10:44:57 +00:00

85 lines
2.5 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.8 -->
<refentry id="function.strrpos">
<refnamediv>
<refname>strrpos</refname>
<refpurpose>
Find position of last occurrence of a char in a string
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>strrpos</methodname>
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
<methodparam><type>char</type><parameter>needle</parameter></methodparam>
</methodsynopsis>
<para>
Returns the numeric position of the last occurrence of
<parameter>needle</parameter> in the
<parameter>haystack</parameter> string. Note that the needle in
this case can only be a single character. If a string is passed
as the needle, then only the first character of that string will
be used.
</para>
<para>
If <parameter>needle</parameter> is not found, returns &false;.
</para>
<para>
It is easy to mistake the return values for "character found at
position 0" and "character not found". Here's how to detect
the difference:
<informalexample>
<programlisting role="php">
<![CDATA[
// in PHP 4.0b3 and newer:
$pos = strrpos($mystring, "b");
if ($pos === false) { // note: three equal signs
// not found...
}
// in versions older than 4.0b3:
$pos = strrpos($mystring, "b");
if (is_string($pos) && !$pos) {
// not found...
}
]]>
</programlisting>
</informalexample>
</para>
<para>
If <parameter>needle</parameter> is not a string, it is converted
to an integer and applied as the ordinal value of a character.
</para>
<para>
See also <function>strpos</function>,
<function>strripos</function>,
<function>strrchr</function>,
<function>substr</function>,
<function>stristr</function>, and
<function>strstr</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
-->