<!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>Get part of string</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mb-substr-count.html">mb_substr_count</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.pspell.html">Pspell</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-substr" class="refentry"> <div class="refnamediv"> <h1 class="refname">mb_substr</h1> <p class="verinfo">(PHP 4 >= 4.0.6, PHP 5)</p><p class="refpurpose"><span class="refname">mb_substr</span> — <span class="dc-title">Get part of string</span></p> </div> <div class="refsect1 description" id="refsect1-function.mb-substr-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>mb_substr</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></span> , <span class="methodparam"><span class="type">int</span> <code class="parameter">$start</code></span> [, <span class="methodparam"><span class="type">int</span> <code class="parameter">$length</code><span class="initializer"> = NULL</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 multi-byte safe <span class="function"><a href="function.substr.html" class="function">substr()</a></span> operation based on number of characters. Position is counted from the beginning of <em><code class="parameter">str</code></em>. First character's position is 0. Second character position is 1, and so on. </p> </div> <div class="refsect1 parameters" id="refsect1-function.mb-substr-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">str</code></em></span> <dd> <p class="para"> The <span class="type"><a href="language.types.string.html" class="type string">string</a></span> to extract the substring from. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">start</code></em></span> <dd> <p class="para"> Position of first character to use from <em><code class="parameter">str</code></em>. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">length</code></em></span> <dd> <p class="para"> Maximum number of characters to use from <em><code class="parameter">str</code></em>. If omitted or <em>NULL</em> is passed, extract all characters to the end of the string. </p> </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-substr-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> <span class="function"><strong>mb_substr()</strong></span> returns the portion of <em><code class="parameter">str</code></em> specified by the <em><code class="parameter">start</code></em> and <em><code class="parameter">length</code></em> parameters. </p> </div> <div class="refsect1 seealso" id="refsect1-function.mb-substr-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.mb-strcut.html" class="function" rel="rdfs-seeAlso">mb_strcut()</a> - Get part of 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> </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-substr-count.html">mb_substr_count</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.pspell.html">Pspell</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>