downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the Git repository for this website on git.php.net.

Source of: /manual/en/function.grapheme-strlen.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.intl.grapheme.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.grapheme-strlen.php',
   
1 => 'grapheme_strlen',
  ),
 
'up' =>
  array (
   
0 => 'ref.intl.grapheme.php',
   
1 => 'Grapheme Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.grapheme-stristr.php',
   
1 => 'grapheme_stristr',
  ),
 
'next' =>
  array (
   
0 => 'function.grapheme-strpos.php',
   
1 => 'grapheme_strpos',
  ),
 
'alternatives' =>
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.grapheme-strlen" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">grapheme_strlen</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">grapheme_strlen</span> &mdash; <span class="dc-title">Get string length in grapheme units</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.grapheme-strlen-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"><strong>grapheme_strlen</strong></span>
    ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$input</code></span>
   )</div>

  <p class="para rdfs-comment">
   Get string length in grapheme units (not bytes or characters)
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.grapheme-strlen-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">input</code></em></span>
     <dd>

      <p class="para">
       The string being measured for length. It must be a valid UTF-8 string.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

  
 
 <div class="refsect1 returnvalues" id="refsect1-function.grapheme-strlen-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The length of the string on success, and 0 if the string is empty.  
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.grapheme-strlen-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-2595">
   <p><strong>Example #1  <span class="function"><strong>grapheme_strlen()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$char_a_ring_nfd&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"a\xCC\x8A"</span><span style="color: #007700">;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;'LATIN&nbsp;SMALL&nbsp;LETTER&nbsp;A&nbsp;WITH&nbsp;RING&nbsp;ABOVE'&nbsp;(U+00E5)&nbsp;normalization&nbsp;form&nbsp;"D"<br /></span><span style="color: #0000BB">$char_o_diaeresis_nfd&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"o\xCC\x88"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;'LATIN&nbsp;SMALL&nbsp;LETTER&nbsp;O&nbsp;WITH&nbsp;DIAERESIS'&nbsp;(U+00F6)&nbsp;normalization&nbsp;form&nbsp;"D"<br /><br /></span><span style="color: #007700">print&nbsp;</span><span style="color: #0000BB">grapheme_strlen</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'abc'&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$char_a_ring_nfd&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$char_o_diaeresis_nfd&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">$char_a_ring_nfd</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <p class="para">The above example will output:</p>
  <div class="example-contents screen">
<div class="cdata"><pre>
6
</pre></div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.grapheme-strlen-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
     <li class="member">
      <a href="http://unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries" class="link external">&raquo;&nbsp;
       Unicode Text Segmentation: Grapheme Cluster Boundaries
      </a>
     </li>
   </ul>
  </p>
 </div>

</div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites