<!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>Return width 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-strtoupper.html">mb_strtoupper</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mb-substitute-character.html">mb_substitute_character</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-strwidth" class="refentry"> <div class="refnamediv"> <h1 class="refname">mb_strwidth</h1> <p class="verinfo">(PHP 4 >= 4.0.6, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">mb_strwidth</span> — <span class="dc-title">Return width of string</span></p> </div> <div class="refsect1 description" id="refsect1-function.mb-strwidth-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>mb_strwidth</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$str</code></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"> Returns the width of <span class="type"><a href="language.types.string.html" class="type string">string</a></span> <code class="parameter">str</code>, where halfwidth characters count as <em>1</em>, and fullwidth characters count as <em>2</em>. </p> <p class="para"> The fullwidth characters are: <em>U+1100</em>-<em>U+115F</em>, <em>U+11A3</em>-<em>U+11A7</em>, <em>U+11FA</em>-<em>U+11FF</em>, <em>U+2329</em>-<em>U+232A</em>, <em>U+2E80</em>-<em>U+2E99</em>, <em>U+2E9B</em>-<em>U+2EF3</em>, <em>U+2F00</em>-<em>U+2FD5</em>, <em>U+2FF0</em>-<em>U+2FFB</em>, <em>U+3000</em>-<em>U+303E</em>, <em>U+3041</em>-<em>U+3096</em>, <em>U+3099</em>-<em>U+30FF</em>, <em>U+3105</em>-<em>U+312D</em>, <em>U+3131</em>-<em>U+318E</em>, <em>U+3190</em>-<em>U+31BA</em>, <em>U+31C0</em>-<em>U+31E3</em>, <em>U+31F0</em>-<em>U+321E</em>, <em>U+3220</em>-<em>U+3247</em>, <em>U+3250</em>-<em>U+32FE</em>, <em>U+3300</em>-<em>U+4DBF</em>, <em>U+4E00</em>-<em>U+A48C</em>, <em>U+A490</em>-<em>U+A4C6</em>, <em>U+A960</em>-<em>U+A97C</em>, <em>U+AC00</em>-<em>U+D7A3</em>, <em>U+D7B0</em>-<em>U+D7C6</em>, <em>U+D7CB</em>-<em>U+D7FB</em>, <em>U+F900</em>-<em>U+FAFF</em>, <em>U+FE10</em>-<em>U+FE19</em>, <em>U+FE30</em>-<em>U+FE52</em>, <em>U+FE54</em>-<em>U+FE66</em>, <em>U+FE68</em>-<em>U+FE6B</em>, <em>U+FF01</em>-<em>U+FF60</em>, <em>U+FFE0</em>-<em>U+FFE6</em>, <em>U+1B000</em>-<em>U+1B001</em>, <em>U+1F200</em>-<em>U+1F202</em>, <em>U+1F210</em>-<em>U+1F23A</em>, <em>U+1F240</em>-<em>U+1F248</em>, <em>U+1F250</em>-<em>U+1F251</em>, <em>U+20000</em>-<em>U+2FFFD</em>, <em>U+30000</em>-<em>U+3FFFD</em>. All other characters are halfwidth characters. </p> </div> <div class="refsect1 parameters" id="refsect1-function.mb-strwidth-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <code class="parameter">str</code></dt> <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> <code class="parameter">encoding</code></dt> <dd> <p class="para">The <code class="parameter">encoding</code> parameter is the character encoding. If it is omitted, the internal character encoding value will be used.</p> </dd> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.mb-strwidth-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The width of <span class="type"><a href="language.types.string.html" class="type string">string</a></span> <code class="parameter">str</code>. </p> </div> <div class="refsect1 seealso" id="refsect1-function.mb-strwidth-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><span class="function"><a href="function.mb-strimwidth.html" class="function" rel="rdfs-seeAlso">mb_strimwidth()</a> - Get truncated string with specified width</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-strtoupper.html">mb_strtoupper</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.mb-substitute-character.html">mb_substitute_character</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>