downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | 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 SVN repository for this website on svn.php.net.

Source of: /manual/en/function.iconv-substr.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/ref.iconv.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.iconv-substr.php',
   
1 => 'iconv_substr',
  ),
 
'up' =>
  array (
   
0 => 'ref.iconv.php',
   
1 => 'iconv Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.iconv-strrpos.php',
   
1 => 'iconv_strrpos',
  ),
 
'next' =>
  array (
   
0 => 'function.iconv.php',
   
1 => 'iconv',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.iconv-substr" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">iconv_substr</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">iconv_substr</span> &mdash; <span class="dc-title">Cut out part of a string</span></p>

 </div>
 
 <a name="function.iconv-substr.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><b>iconv_substr</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$str</tt></span>
   , <span class="methodparam"><span class="type">int</span> <tt class="parameter">$offset</tt></span>
   [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$length</tt><span class="initializer"> = strlen($str)</span></span>
   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$charset</tt><span class="initializer"> = ini_set(&quot;iconv.internal_encoding&quot;)</span></span>
  ]] )</div>

  <p class="para rdfs-comment">
   Cuts a portion of <i><tt class="parameter">str</tt></i>
 specified by the
   <i><tt class="parameter">offset</tt></i>
 and <i><tt class="parameter">length</tt></i>
 parameters.
  </p>
 </div>


 <a name="function.iconv-substr.parameters"></a><div class="refsect1 parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   </p><dl>

    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">str</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       The original string.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">offset</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       If <i><tt class="parameter">offset</tt></i>
 is non-negative,
       <b>iconv_substr()</b> cuts the portion out of
       <i><tt class="parameter">str</tt></i>
 beginning at <i><tt class="parameter">offset</tt></i>
&#039;th
       character, counting from zero.
      </p>
      <p class="para">
       If <i><tt class="parameter">offset</tt></i>
 is negative,
       <b>iconv_substr()</b> cuts out the portion beginning
       at the position, <i><tt class="parameter">offset</tt></i>
 characters
       away from the end of <i><tt class="parameter">str</tt></i>
.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">length</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       If <i><tt class="parameter">length</tt></i>
 is given and is positive, the return
       value will contain at most <i><tt class="parameter">length</tt></i>
 characters
       of the portion that begins at <i><tt class="parameter">offset</tt></i>

       (depending on the length of <i><tt class="parameter">string</tt></i>
).
      </p>
      <p class="para">
       If negative <i><tt class="parameter">length</tt></i>
 is passed,
       <b>iconv_substr()</b> cuts the portion out of
       <i><tt class="parameter">str</tt></i>
 from the <i><tt class="parameter">offset</tt></i>
&#039;th
       character up to the character that is
       <i><tt class="parameter">length</tt></i>
 characters away from the end of the string.
       In case <i><tt class="parameter">offset</tt></i>
 is also negative, the start position
       is calculated beforehand according to the rule explained above.
      </p>
     </dd>

   
    <dt class="varlistentry">

     <span class="term"><i><tt class="parameter">charset</tt></i>
</span>

     </dt><dd class="listitem">

      <p class="para">
       If <i><tt class="parameter">charset</tt></i>
 parameter is omitted,
       <i><tt class="parameter">string</tt></i>
 are assumed to be encoded in
       <a href="iconv.configuration.php" class="link">iconv.internal_encoding</a>.
      </p>
      <p class="para">
       Note that <i><tt class="parameter">offset</tt></i>
 and <i><tt class="parameter">length</tt></i>

       parameters are always deemed to represent offsets that are
       calculated on the basis of the character set determined by
       <i><tt class="parameter">charset</tt></i>
, whilst the counterpart
       <a href="function.substr.php" class="function">substr()</a> always takes these for byte offsets.
      </p>
     </dd>

   
   </dl>
<p>
  </p>
 </div>


 <a name="function.iconv-substr.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the portion of <i><tt class="parameter">str</tt></i>
 specified by the
   <i><tt class="parameter">offset</tt></i>
 and <i><tt class="parameter">length</tt></i>
 parameters.
  </p>
  <p class="para">
   If <i><tt class="parameter">str</tt></i>
 is shorter than <i><tt class="parameter">offset</tt></i>

   characters long, <b><tt class="constant">FALSE</tt></b> will be returned.
  </p>
 </div>


 <a name="function.iconv-substr.seealso"></a><div class="refsect1 seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   </p><ul class="simplelist">
    <li class="member"><a href="function.substr.php" class="function" rel="rdfs-seeAlso">substr()</a> - Return part of a string</li>
    <li class="member"><a href="function.mb-substr.php" class="function" rel="rdfs-seeAlso">mb_substr()</a> - Get part of string</li>
    <li class="member"><a href="function.mb-strcut.php" class="function" rel="rdfs-seeAlso">mb_strcut()</a> - Get part of string</li>
   </ul><p>
  </p>
 </div>


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