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-strpos.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-strpos.php',
   
1 => 'iconv_strpos',
  ),
 
'up' =>
  array (
   
0 => 'ref.iconv.php',
   
1 => 'iconv Functions',
  ),
 
'prev' =>
  array (
   
0 => 'function.iconv-strlen.php',
   
1 => 'iconv_strlen',
  ),
 
'next' =>
  array (
   
0 => 'function.iconv-strrpos.php',
   
1 => 'iconv_strrpos',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="function.iconv-strpos" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">iconv_strpos</h1>
  <p class="verinfo">(PHP 5)</p><p class="refpurpose"><span class="refname">iconv_strpos</span> &mdash; <span class="dc-title">Finds position of first occurrence of a needle within a haystack</span></p>

 </div>
 
 <a name="function.iconv-strpos.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>iconv_strpos</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">int</span> <tt class="parameter">$offset</tt><span class="initializer"> = 0</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">
   Finds position of first occurrence of a needle within a haystack.
  </p>
  <p class="para">
   In contrast to <a href="function.strpos.php" class="function">strpos()</a>, the return value of
   <b>iconv_strpos()</b> is the number of characters that
   appear before the needle, rather than the offset in bytes to the
   position where the needle has been found. The characters are counted
   on the basis of the specified character set <i><tt class="parameter">charset</tt></i>
.
  </p>
 </div>


 <a name="function.iconv-strpos.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 entire string.
      </p>
     </dd>

   
    <dt class="varlistentry">

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

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

      <p class="para">
       The searched substring.
      </p>
     </dd>

   
    <dt class="varlistentry">

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

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

      <p class="para">
       The optional <i><tt class="parameter">offset</tt></i>
 parameter specifies
       the position from which the search should be performed.
      </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>
     </dd>

   
   </dl>
<p>
  </p>
  <p class="para">
   If <i><tt class="parameter">haystack</tt></i>
 or <i><tt class="parameter">needle</tt></i>
 is
   not a string, it is converted to a string and applied as the ordinal
   value of a character.
  </p>
 </div>


 <a name="function.iconv-strpos.returnvalues"></a><div class="refsect1 returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the numeric position of the first occurrence of
   <i><tt class="parameter">needle</tt></i>
 in <i><tt class="parameter">haystack</tt></i>
.
  </p>
  <p class="para">
   If <i><tt class="parameter">needle</tt></i>
 is not found,
   <b>iconv_strpos()</b> will return <b><tt class="constant">FALSE</tt></b>.
  </p>
  <div class="warning"><b class="warning">Warning</b><p class="simpara">This function may
return Boolean <b><tt class="constant">FALSE</tt></b>, but may also return a non-Boolean value which
evaluates to <b><tt class="constant">FALSE</tt></b>, such as <i>0</i> or
&quot;&quot;. Please read the section on <a href="language.types.boolean.php" class="link">Booleans</a> for more
information. Use <a href="language.operators.comparison.php" class="link">the ===
operator</a> for testing the return value of this
function.</p></div>
 </div>


 <a name="function.iconv-strpos.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.strpos.php" class="function" rel="rdfs-seeAlso">strpos()</a> - Find position of first occurrence of a string</li>
    <li class="member"><a href="function.iconv-strrpos.php" class="function" rel="rdfs-seeAlso">iconv_strrpos()</a> - Finds the last occurrence of a needle within a haystack</li>
    <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>
   </ul><p>
  </p>
 </div>


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