📄 function.iconv-strpos.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Finds position of first occurrence of a needle within a haystack</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.iconv-strlen.html">iconv_strlen</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.iconv-strrpos.html">iconv_strrpos</a></div> <div class="up"><a href="ref.iconv.html">iconv Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><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> — <span class="dc-title">Finds position of first occurrence of a needle within a haystack</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><b><b>iconv_strpos</b></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> [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$charset</tt></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.html" 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> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">haystack</tt></i></span> <dd> <p class="para"> The entire string. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">needle</tt></i></span> <dd> <p class="para"> The searched substring. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">offset</tt></i></span> <dd> <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> <dt> <span class="term"><i><tt class="parameter">charset</tt></i></span> <dd> <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.html" class="link">iconv.internal_encoding</a>. </p> </dd> </dt> </dl> </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> <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>FALSE</tt></b>. </p> <div class="warning"><b class="warning">Warning</b><p class="simpara">This function mayreturn Boolean <b><tt>FALSE</tt></b>, but may also return a non-Boolean value whichevaluates to <b><tt>FALSE</tt></b>, such as <i>0</i> or"". Please read the section on <a href="language.types.boolean.html" class="link">Booleans</a> for moreinformation. Use <a href="language.operators.comparison.html" class="link">the ===operator</a> for testing the return value of thisfunction.</p></div> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.strpos.html" class="function" rel="rdfs-seeAlso">strpos()</a></li> <li class="member"><a href="function.iconv-strrpos.html" class="function" rel="rdfs-seeAlso">iconv_strrpos()</a></li> <li class="member"><a href="function.mb-strpos.html" class="function" rel="rdfs-seeAlso">mb_strpos()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.iconv-strlen.html">iconv_strlen</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.iconv-strrpos.html">iconv_strrpos</a></div> <div class="up"><a href="ref.iconv.html">iconv Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -