<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.mbstring.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.mb-strcut.php',
    1 => 'mb_strcut',
    2 => '文字列の一部を得る',
  ),
  'up' => 
  array (
    0 => 'ref.mbstring.php',
    1 => 'マルチバイト文字列 関数',
  ),
  'prev' => 
  array (
    0 => 'function.mb-str-split.php',
    1 => 'mb_str_split',
  ),
  'next' => 
  array (
    0 => 'function.mb-strimwidth.php',
    1 => 'mb_strimwidth',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/mbstring/functions/mb-strcut.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.mb-strcut" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_strcut</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">mb_strcut</span> &mdash; <span class="dc-title">文字列の一部を得る</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.mb-strcut-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>mb_strcut</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">$start</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"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$encoding</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><a href="language.types.string.php" class="type string">string</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>mb_strcut()</strong></span> は、ある文字列からの部分文字列の抽出を
   <span class="function"><a href="function.mb-substr.php" class="function">mb_substr()</a></span> と同じ方法で行います。ただし、
   処理は文字単位ではなくバイト単位で行います。
   切り出し位置がたまたまマルチバイト文字の 2 バイト目以降だった場合、
   切り出しはその文字の最初のバイトから行われます。この挙動もまた
   <span class="function"><a href="function.substr.php" class="function">substr()</a></span> 関数と異なるところです。
   <span class="function"><a href="function.substr.php" class="function">substr()</a></span> の場合は、
   マルチバイト文字の 2 バイト目以降であってもその位置から切り出しを行い、
   結果的に壊れたバイト列を返すことになります。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.mb-strcut-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       取り出しの対象となる文字列。
      </p>
     </dd>
    
    
     <dt><code class="parameter">start</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">start</code> が非負である場合に返される文字列は、
       <code class="parameter">string</code> の <code class="parameter">start</code> <em>バイト</em>目以降の文字列となります (ゼロから数えます)。
       たとえば、文字列 &#039;<code class="literal">abcdef</code>&#039; の
       <code class="literal">0</code> バイト目は &#039;<code class="literal">a</code>&#039; で、
       <code class="literal">2</code> バイト目は &#039;<code class="literal">c</code>&#039; のようになります。
      </p>
      <p class="para">
       <code class="parameter">start</code> が負の場合に返される文字列は、
       <code class="parameter">string</code> の後ろから数えて <code class="parameter">start</code> バイト目以降となります。 
       負の <code class="parameter">start</code> の絶対値が文字列の長さよりも大きい場合、
       返される文字列は、<code class="parameter">string</code> の先頭から始まります。
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       <em>バイト</em>単位での長さ。
       省略したり <code class="literal">NULL</code> を指定したりした場合は、
       文字列の最後までの全バイトを取り出します。
      </p>
      <p class="para">
       <code class="parameter">length</code> が負の場合、返される文字列は
       <code class="parameter">string</code> の後ろから数えて
       <code class="parameter">length</code> バイト目で終了します。
       しかし、負の <code class="parameter">length</code> の絶対値が
       <code class="parameter">start</code> の位置を超える場合、空の文字列が返されます。
      </p>
     </dd>
    
    
     <dt><code class="parameter">encoding</code></dt>
     <dd>
      <p class="para"><code class="parameter">encoding</code>
パラメータには文字エンコーディングを指定します。省略した場合、もしくは <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> の場合は、
内部文字エンコーディングを使用します。</p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.mb-strcut-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   <span class="function"><strong>mb_strcut()</strong></span> は、
   <code class="parameter">start</code> および
   <code class="parameter">length</code> パラメータで指定した
   <code class="parameter">string</code> の一部を返します。
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">encoding</code> は、nullable になりました。
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-function.mb-strcut-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.mb-substr.php" class="function" rel="rdfs-seeAlso">mb_substr()</a> - 文字列の一部を得る</span></li>
    <li><span class="function"><a href="function.mb-internal-encoding.php" class="function" rel="rdfs-seeAlso">mb_internal_encoding()</a> - 内部文字エンコーディングを設定あるいは取得する</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>