📄 function.grapheme-substr.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Return part 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-strstr.html">grapheme_strstr</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.intl-error-name.html">intl_error_name</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-substr" class="refentry"> <div class="refnamediv"> <h1 class="refname">grapheme_substr</h1> <p class="verinfo">(No version information available, might be only in CVS)</p><p class="refpurpose"><span class="refname">grapheme_substr</span> — <span class="dc-title">Return part 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_substr</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$string</tt></span> , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$start</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$length</tt></span> ] )</div> <p class="para rdfs-comment"> Return part 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">string</tt></i></span> <dd> <p class="para"> The input string. Must be valid UTF-8. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">start</tt></i></span> <dd> <p class="para"> Start position in default grapheme units. If $start is non-negative, the returned string will start at the $start'th position in $string, counting from zero. If $start is negative, the returned string will start at the $start'th grapheme unit from the end of string. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">length</tt></i></span> <dd> <p class="para"> Length in grapheme units. If $length is given and is positive, the string returned will contain at most $length grapheme units beginning from $start (depending on the length of string). If $string is less than or equal to $start grapheme units long, FALSE will be returned. If $length is given and is negative, then that many grapheme units will be omitted from the end of string (after the start position has been calculated when a start is negative). If $start denotes a position beyond this truncation, an empty string will be returned. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the extracted part of $string. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <div class="example"> <p><b>Example #1 <b>grapheme_substr()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br /><br />$char_a_ring_nfd </span><span style="color: #007700">= </span><span style="color: #DD0000">"a\xCC\x8A"</span><span style="color: #007700">; </span><span style="color: #FF8000">// 'LATIN SMALL LETTER A WITH RING ABOVE' (U+00E5) normalization form "D"<br /></span><span style="color: #0000BB">$char_o_diaeresis_nfd </span><span style="color: #007700">= </span><span style="color: #DD0000">"o\xCC\x88"</span><span style="color: #007700">; </span><span style="color: #FF8000">// 'LATIN SMALL LETTER O WITH DIAERESIS' (U+00F6) normalization form "D"<br /><br /></span><span style="color: #007700">print </span><span style="color: #0000BB">urlencode</span><span style="color: #007700">(</span><span style="color: #0000BB">grapheme_substr</span><span style="color: #007700">( </span><span style="color: #DD0000">"ao" </span><span style="color: #007700">. </span><span style="color: #0000BB">$char_a_ring_nfd </span><span style="color: #007700">. </span><span style="color: #DD0000">"bc" </span><span style="color: #007700">. </span><span style="color: #0000BB">$char_o_diaeresis_nfd </span><span style="color: #007700">. </span><span style="color: #DD0000">"O"</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">, -</span><span style="color: #0000BB">1 </span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> <p class="para">The above example will output:</p> <div class="example-contents"><pre><div class="cdata"><pre>a%CC%8Abco%CC%88</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-extract.html" class="function" rel="rdfs-seeAlso">grapheme_extract()</a></li> <li class="member"><b>grapheme_extractB()</b></li> <li class="member"> <a href="http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries" class="link external">» 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-strstr.html">grapheme_strstr</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.intl-error-name.html">intl_error_name</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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -