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.mb-substr-count.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = 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 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'function.mb-substr-count.php',
   
1 => 'mb_substr_count',
  ),
 
'up' =>
  array (
   
0 => 'ref.mbstring.php',
   
1 => 'Multibyte String Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.mb-substitute-character.php',
   
1 => 'mb_substitute_character',
  ),
 
'next' =>
  array (
   
0 => 'function.mb-substr.php',
   
1 => 'mb_substr',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.mb-substr-count" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">mb_substr_count</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5)</p><p class="refpurpose"><span class="refname">mb_substr_count</span> &mdash; <span class="dc-title">Count the number of substring occurrences</span></p>

 </div>
  
 <a name="function.mb-substr-count.description"></a><div class="refsect1 description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">int</span> <span class="methodname"><b>mb_substr_count</b></span>
    ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$haystack</tt></span>
   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$needle</tt></span>
   [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$encoding</tt></span>
  ] )</div>

  <p class="para rdfs-comment">
   Counts the number of times the
   <i><tt class="parameter">needle</tt></i>
 substring occurs in the
   <i><tt class="parameter">haystack</tt></i>
 <a href="language.types.string.php" class="type string">string</a>.
  </p>
 </div>


 <a name="function.mb-substr-count.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">haystack</tt></i>
</span>

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

      <p class="para">
       The <a href="language.types.string.php" class="type string">string</a> being checked.
      </p>
     </dd>

   
    <dt class="varlistentry">

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

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

      <p class="para">
       The <a href="language.types.string.php" class="type string">string</a> being found.
      </p>
     </dd>

   
    <dt class="varlistentry">

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

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

      <p class="para">The <i><tt class="parameter">encoding</tt></i>

parameter is the character encoding. If it is omitted, the internal character
encoding value will be used.</p>
     </dd>

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


 <a name="function.mb-substr-count.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The number of times the
   <i><tt class="parameter">needle</tt></i>
 substring occurs in the
   <i><tt class="parameter">haystack</tt></i>
 <a href="language.types.string.php" class="type string">string</a>.
  </p>
 </div>


 <a name="function.mb-substr-count.examples"></a><div class="refsect1 examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   </p><div class="example">
    <p><b>Example #1 <b>mb_substr_count()</b> example</b></p>
    <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">mb_substr_count</span><span style="color: #007700">(</span><span style="color: #DD0000">"This&nbsp;is&nbsp;a&nbsp;test"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"is"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;prints&nbsp;out&nbsp;2<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

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


 <a name="function.mb-substr-count.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.mb-strpos.php" class="function" rel="rdfs-seeAlso">mb_strpos()</a> - Find position of first occurrence of string in 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.substr-count.php" class="function" rel="rdfs-seeAlso">substr_count()</a> - Count the number of substring occurrences</li>
   </ul><p>
  </p>
 </div>


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