<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = 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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.grapheme-substr.php',
    1 => 'grapheme_substr',
    2 => '部分文字列を返す',
  ),
  'up' => 
  array (
    0 => 'ref.intl.grapheme.php',
    1 => 'Grapheme 関数',
  ),
  'prev' => 
  array (
    0 => 'function.grapheme-strstr.php',
    1 => 'grapheme_strstr',
  ),
  'next' => 
  array (
    0 => 'ref.intl.idn.php',
    1 => 'IDN 関数',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/intl/grapheme/grapheme-substr.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.grapheme-substr" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">grapheme_substr</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">grapheme_substr</span> &mdash; <span class="dc-title">部分文字列を返す</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.grapheme-substr-description">
  <h3 class="title">説明</h3>
  <p class="para">手続き型</p>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>grapheme_substr</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$offset</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.integer.php" class="type int">int</a></span></span> <code class="parameter">$length</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$locale</code><span class="initializer"> = &quot;&quot;</span></span><br>): <span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   部分文字列を返します。
  </p> 
 </div>


 <div class="refsect1 parameters" id="refsect1-function.grapheme-substr-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       入力文字列。正しい形式の UTF-8 でなければなりません。
      </p>
     </dd>
    
    
     <dt><code class="parameter">offset</code></dt>
     <dd>
      <p class="para">
       デフォルトの書記素単位での開始位置。
       <code class="parameter">offset</code> がゼロ以上である場合は、<code class="parameter">string</code> の
       <code class="parameter">offset</code> 番目の位置から始まる文字列を返します。位置はゼロから数え始めます。
       <code class="parameter">offset</code> が負の場合は、文字列の末尾から数えて
       <code class="parameter">offset</code> 番目 (書記素単位) の位置以降の文字列を返します。
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       長さを書記素単位で指定します。
       <code class="parameter">length</code> が正の値の場合は、<code class="parameter">offset</code> から数えて最大
       <code class="parameter">length</code> 文字までの文字列を返します (文字列全体の長さによって変わります)。
       <code class="parameter">length</code> が負の値の場合は、文字列の末尾から多くの書記素が削除されます
       (<code class="parameter">offset</code> が負の場合にはまず開始位置を算出してから行います)。
        <code class="parameter">offset</code> がこの削除された場所以降になる場合は、空文字列を返します。
      </p>
     </dd>
    
    
     <dt><code class="parameter">locale</code></dt>
     <dd>
      <span class="simpara">使用するロケール。</span>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.grapheme-substr-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   <code class="parameter">string</code> の部分文字列を返します。
   失敗した場合に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.grapheme-substr-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.5.0</td>
 <td>
  オプションのパラメータ <code class="parameter">locale</code> が追加されました。
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       この関数は、offset が文字列境界の範囲外になる場合を一貫した形で扱うようになりました。
       これより前のバージョンでは、
       場合によっては空文字列ではなく <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返すことがありました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.grapheme-substr-examples">
  <h3 class="title">例</h3>
  <div class="example" id="example-1">
   <p><strong>例1 <span class="function"><strong>grapheme_substr()</strong></span> の例</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 </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">?&gt;</span></span></code></div>
   </div>

  </div>
  <p class="para">上の例の出力は以下となります。</p>
  <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">a%CC%8Abco%CC%88</pre>
</div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.grapheme-substr-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.grapheme-extract.php" class="function" rel="rdfs-seeAlso">grapheme_extract()</a> - デフォルトの書記素クラスタシーケンスをテキストバッファから取り出す関数。
   テキストは UTF-8 でエンコードされている必要があります</span></li>
    <li>
     <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($setup); ?>