function.grapheme-strrpos.html

来自「php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容」· HTML 代码 · 共 143 行

HTML
143
字号
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Find position (in grapheme units) of last occurrence of a string</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.grapheme-strripos.html">grapheme_strripos</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.grapheme-strstr.html">grapheme_strstr</a></div> <div class="up"><a href="ref.intl.html">intl Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.grapheme-strrpos" class="refentry"> <div class="refnamediv">  <h1 class="refname">grapheme_strrpos</h1>  <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">grapheme_strrpos</span> &mdash; <span class="dc-title">Find position (in grapheme units) of last occurrence of a string</span></p> </div> <div class="refsect1 description">  <h3 class="title">Description</h3>  <p class="para">Procedural style</p>  <div class="methodsynopsis dc-description">   <span class="type">int</span> <span class="methodname"><b><b>grapheme_strrpos</b></b></span>    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$haystack</tt></span>   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$needle</tt></span>   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$offset</tt></span>  ] )</div>  <p class="para rdfs-comment">   Find position (in grapheme units) of last occurrence of a string  </p>   </div> <div class="refsect1 parameters">  <h3 class="title">Parameters</h3>  <p class="para">   <dl>    <dt>     <span class="term"><i><tt class="parameter">haystack</tt></i></span>     <dd>      <p class="para">       The string to look in. Must be valid UTF-8.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">needle</tt></i></span>     <dd>      <p class="para">       The string to look for. Must be valid UTF-8.      </p>     </dd>    </dt>    <dt>     <span class="term"><i><tt class="parameter">offset</tt></i></span>     <dd>      <p class="para">       The optional $offset parameter allows you to specify where in $haystack to       start searching as an offset in grapheme units (not bytes or characters). If not given, the default is zero.         The position returned is still relative to the beginning of haystack       regardless of the value of $offset.      </p>     </dd>    </dt>   </dl>  </p> </div>     <div class="refsect1 returnvalues">  <h3 class="title">Return Values</h3>  <p class="para">   Returns the position as an integer. If needle is not found, grapheme_strrpos() will return boolean FALSE.     </p> </div>  <div class="refsect1 examples">  <h3 class="title">Examples</h3>  <div class="example">   <p><b>Example #1 <b>grapheme_strrpos()</b> example</b></p>   <div class="example-contents"><div class="phpcode"><code><span style="color: #000000">&lt;&nbsp;?php<br /><br />$char_a_ring_nfd&nbsp;=&nbsp;"a\xCC\x8A";&nbsp;&nbsp;//&nbsp;'LATIN&nbsp;SMALL&nbsp;LETTER&nbsp;A&nbsp;WITH&nbsp;RING&nbsp;ABOVE'&nbsp;(U+00E5)&nbsp;normalization&nbsp;form&nbsp;"D"<br />$char_o_diaeresis_nfd&nbsp;=&nbsp;"o\xCC\x88";&nbsp;//&nbsp;'LATIN&nbsp;SMALL&nbsp;LETTER&nbsp;O&nbsp;WITH&nbsp;DIAERESIS'&nbsp;(U+00F6)&nbsp;normalization&nbsp;form&nbsp;"D"<br /><br />print&nbsp;grapheme_strrpos(&nbsp;$char_a_ring_nfd&nbsp;.&nbsp;$char_o_diaeresis_nfd&nbsp;.&nbsp;$char_o_diaeresis_nfd,&nbsp;$char_o_diaeresis_nfd);<br /><br />?&gt;</span></code></div>   </div>  </div>  <p class="para">The above example will output:</p>  <div class="example-contents"><pre><div class="cdata"><pre>2</pre></div>  </pre></div> </div> <div class="refsect1 seealso">  <h3 class="title">See Also</h3>  <p class="para">   <ul class="simplelist">    <li class="member"><a href="function.grapheme-stripos.html" class="function" rel="rdfs-seeAlso">grapheme_stripos()</a></li>    <li class="member"><a href="function.grapheme-stristr.html" class="function" rel="rdfs-seeAlso">grapheme_stristr()</a></li>    <li class="member"><a href="function.grapheme-strpos.html" class="function" rel="rdfs-seeAlso">grapheme_strpos()</a></li>    <li class="member"><a href="function.grapheme-strripos.html" class="function" rel="rdfs-seeAlso">grapheme_strripos()</a></li>    <li class="member"><a href="function.grapheme-strstr.html" class="function" rel="rdfs-seeAlso">grapheme_strstr()</a></li>    <li class="member">     <a href="http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries" class="link external">&raquo;       Unicode Text Segmentation: Grapheme Cluster Boundaries     </a>    </li>   </ul>  </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.grapheme-strripos.html">grapheme_strripos</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.grapheme-strstr.html">grapheme_strstr</a></div> <div class="up"><a href="ref.intl.html">intl Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?