<!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 truncated string with specified width</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.mb-strcut.html">mb_strcut</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mb-stripos.html">mb_stripos</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-strimwidth" class="refentry"> <div class="refnamediv"> <h1 class="refname">mb_strimwidth</h1> <p class="verinfo">(PHP 4 >= 4.0.6, PHP 5)</p><p class="refpurpose"><span class="refname">mb_strimwidth</span> — <span class="dc-title">Get truncated string with specified width</span></p> </div> <div class="refsect1 description" id="refsect1-function.mb-strimwidth-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><strong>mb_strimwidth</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">$width</code></span> [, <span class="methodparam"><span class="type">string</span> <code class="parameter">$trimmarker</code><span class="initializer"> = ""</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"> Truncates <span class="type"><a href="language.types.string.html" class="type string">string</a></span> <em><code class="parameter">str</code></em> to specified <em><code class="parameter">width</code></em>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.mb-strimwidth-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> being decoded. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">start</code></em></span> <dd> <p class="para"> The start position offset. Number of characters from the beginning of string. (First character is 0) </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">width</code></em></span> <dd> <p class="para"> The width of the desired trim. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">trimmarker</code></em></span> <dd> <p class="para"> A string that is added to the end of string when string is truncated. </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-strimwidth-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The truncated <span class="type"><a href="language.types.string.html" class="type string">string</a></span>. If <em><code class="parameter">trimmarker</code></em> is set, <em><code class="parameter">trimmarker</code></em> is appended to the return value. </p> </div> <div class="refsect1 examples" id="refsect1-function.mb-strimwidth-examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example" id="example-2718"> <p><strong>Example #1 <span class="function"><strong>mb_strimwidth()</strong></span> example</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">mb_strimwidth</span><span style="color: #007700">(</span><span style="color: #DD0000">"Hello World"</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">10</span><span style="color: #007700">, </span><span style="color: #DD0000">"..."</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// outputs Hello W...<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.mb-strimwidth-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.mb-strwidth.html" class="function" rel="rdfs-seeAlso">mb_strwidth()</a> - Return width 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-strcut.html">mb_strcut</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mb-stripos.html">mb_stripos</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>