<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Find position of last occurrence of a string in a string</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mb-strripos.html">mb_strripos</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mb-strstr.html">mb_strstr</a></div> <div class="up"><a href="ref.mbstring.html">Multibyte String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.mb-strrpos" class="refentry"> <div class="refnamediv"> <h1 class="refname">mb_strrpos</h1> <p class="verinfo">(PHP 4 >= 4.0.6, PHP 5)</p><p class="refpurpose"><span class="refname">mb_strrpos</span> — <span class="dc-title">Find position of last occurrence of a string in a string</span></p> </div> <div class="refsect1 description" id="refsect1-function.mb-strrpos-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>mb_strrpos</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$haystack</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter">$needle</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$offset</code><span class="initializer"> = 0</span></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$encoding</code><span class="initializer"> = mb_internal_encoding()</span></span> ]] )</div> <p class="para rdfs-comment"> Performs a multibyte safe <span class="function"><a href="function.strrpos.html" class="function">strrpos()</a></span> operation based on the number of characters. <em><code class="parameter">needle</code></em> position is counted from the beginning of <em><code class="parameter">haystack</code></em>. First character's position is 0. Second character position is 1. </p> </div> <div class="refsect1 parameters" id="refsect1-function.mb-strrpos-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">haystack</code></em></span> <dd> <p class="para"> The <span class="type"><a href="language.types.string.html" class="type string">string</a></span> being checked, for the last occurrence of <em><code class="parameter">needle</code></em> </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">needle</code></em></span> <dd> <p class="para"> The <span class="type"><a href="language.types.string.html" class="type string">string</a></span> to find in <em><code class="parameter">haystack</code></em>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">offset</code></em></span> <dd> <span class="simpara"> May be specified to begin searching an arbitrary number of characters into the <span class="type"><a href="language.types.string.html" class="type string">string</a></span>. Negative values will stop searching at an arbitrary point prior to the end of the <span class="type"><a href="language.types.string.html" class="type string">string</a></span>. </span> </dd> </dt> <dt> <span class="term"><em><code class="parameter">encoding</code></em></span> <dd> <p class="para">The <em><code class="parameter">encoding</code></em> parameter is the character encoding. If it is omitted, the internal character encoding value will be used.</p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.mb-strrpos-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the numeric position of the last occurrence of <em><code class="parameter">needle</code></em> in the <em><code class="parameter">haystack</code></em> <span class="type"><a href="language.types.string.html" class="type string">string</a></span>. If <em><code class="parameter">needle</code></em> is not found, it returns <strong><code>FALSE</code></strong>. </p> </div> <div class="refsect1 changelog" id="refsect1-function.mb-strrpos-changelog"> <h3 class="title">Changelog</h3> <p class="para"> <table class="doctable informaltable"> <thead> <tr> <th>Version</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>5.2.0</td> <td>Added the optional parameter <em><code class="parameter">offset</code></em>.</td> </tr> </tbody> </table> </p> </div> <div class="refsect1 notes" id="refsect1-function.mb-strrpos-notes"> <h3 class="title">Notes</h3> <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara"> The <em><code class="parameter">encoding</code></em> parameter was moved from the third position to the fourth in PHP 5.2.0. For backward compatibility, <em><code class="parameter">encoding</code></em> can be specified as the third parameter, but doing so is deprecated and will be removed in the future. </span> </p></blockquote> </div> <div class="refsect1 seealso" id="refsect1-function.mb-strrpos-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.mb-strpos.html" class="function" rel="rdfs-seeAlso">mb_strpos()</a> - Find position of first occurrence of string in a string</span></li> <li class="member"> <span class="function"><a href="function.mb-internal-encoding.html" class="function" rel="rdfs-seeAlso">mb_internal_encoding()</a> - Set/Get internal character encoding</span></li> <li class="member"> <span class="function"><a href="function.strrpos.html" class="function" rel="rdfs-seeAlso">strrpos()</a> - Find the position of the last occurrence of a substring in a string</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mb-strripos.html">mb_strripos</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mb-strstr.html">mb_strstr</a></div> <div class="up"><a href="ref.mbstring.html">Multibyte String Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>