<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.grapheme-strpos.php',
    1 => 'grapheme_strpos',
    2 => 'Find position (in grapheme units) of first occurrence of a string',
  ),
  'up' => 
  array (
    0 => 'ref.intl.grapheme.php',
    1 => 'Grapheme Functions',
  ),
  'prev' => 
  array (
    0 => 'function.grapheme-strlen.php',
    1 => 'grapheme_strlen',
  ),
  'next' => 
  array (
    0 => 'function.grapheme-strripos.php',
    1 => 'grapheme_strripos',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/intl/grapheme/grapheme-strpos.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.grapheme-strpos" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">grapheme_strpos</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_strpos</span> &mdash; <span class="dc-title">Find position (in grapheme units) of first occurrence of a string</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.grapheme-strpos-description">
  <h3 class="title">Description</h3>
  <p class="para">Procedural style</p>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>grapheme_strpos</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">$haystack</code></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">$needle</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 class="initializer"> = 0</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.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   Find position (in grapheme units) of first occurrence of a string
  </p> 
  </div>


 <div class="refsect1 parameters" id="refsect1-function.grapheme-strpos-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">haystack</code></dt>
     <dd>
      <p class="para">
       The string to look in. Must be valid UTF-8.
      </p>
     </dd>
    
    
     <dt><code class="parameter">needle</code></dt>
     <dd>
      <p class="para">
       The string to look for. Must be valid UTF-8.
      </p>
     </dd>
    
    
     <dt><code class="parameter">offset</code></dt>
     <dd>
      <p class="para">
       The optional <code class="parameter">offset</code> parameter allows you to specify where in <code class="parameter">haystack</code> to
       start searching as an offset in grapheme units (not bytes or characters).
       If the offset is negative, it is treated relative to the end of the string.
       The position returned is still relative to the beginning of <code class="parameter">haystack</code>
       regardless of the value of <code class="parameter">offset</code>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">locale</code></dt>
     <dd>
      <span class="simpara">Locale to use.</span>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.grapheme-strpos-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the position as an integer. If <code class="parameter">needle</code> is not found, <span class="function"><strong>grapheme_strpos()</strong></span> will return <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.grapheme-strpos-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.5.0</td>
 <td>
  The optional parameter <code class="parameter">locale</code> has been added.
 </td>
</tr>

     <tr>
      <td>7.1.0</td>
      <td>
       Support for negative <code class="parameter">offset</code>s has been added.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.grapheme-strpos-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="example-1">
   <p><strong>Example #1 <span class="function"><strong>grapheme_strpos()</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 </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">grapheme_strpos</span><span style="color: #007700">( </span><span style="color: #0000BB">$char_a_ring_nfd </span><span style="color: #007700">. </span><span style="color: #0000BB">$char_a_ring_nfd </span><span style="color: #007700">. </span><span style="color: #0000BB">$char_o_diaeresis_nfd</span><span style="color: #007700">, </span><span style="color: #0000BB">$char_o_diaeresis_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="examplescode"><pre class="examplescode">2</pre>
</div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.grapheme-strpos-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.grapheme-stripos.php" class="function" rel="rdfs-seeAlso">grapheme_stripos()</a> - Find position (in grapheme units) of first occurrence of a case-insensitive string</span></li>
    <li><span class="function"><a href="function.grapheme-stristr.php" class="function" rel="rdfs-seeAlso">grapheme_stristr()</a> - Returns part of haystack string from the first occurrence of case-insensitive needle to the end of haystack</span></li>
    <li><span class="function"><a href="function.grapheme-strripos.php" class="function" rel="rdfs-seeAlso">grapheme_strripos()</a> - Find position (in grapheme units) of last occurrence of a case-insensitive string</span></li>
    <li><span class="function"><a href="function.grapheme-strrpos.php" class="function" rel="rdfs-seeAlso">grapheme_strrpos()</a> - Find position (in grapheme units) of last occurrence of a string</span></li>
    <li><span class="function"><a href="function.grapheme-strstr.php" class="function" rel="rdfs-seeAlso">grapheme_strstr()</a> - Returns part of haystack string from the first occurrence of needle to the end of haystack</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); ?>