Initial commit for stripos, a case-insensitive version of strpos.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@117294 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2003-02-20 10:12:42 +00:00
parent 7ffa38ab56
commit d805692756

View file

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<refentry id="function.stripos">
<refnamediv>
<refname>stripos</refname>
<refpurpose>
Find position of first occurrence of a case-insensitive string
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>stripos</methodname>
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
<methodparam><type>string</type><parameter>needle</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>offset</parameter></methodparam>
</methodsynopsis>
<para>
Returns the numeric position of the first occurrence of
<parameter>needle</parameter> in the <parameter>haystack</parameter>
<type>string</type>. Unlike <function> strpos</function>,
<function>stripos</function> is case-insensitive. And unlike
<function>strrpos</function>, this function can take a full string as
the <parameter>needle</parameter> parameter and the entire string will
be used.
</para>
<para>
If <parameter>needle</parameter> is not found,
<function>strpos</function> will return <type>boolean</type> &false;.
</para>
&false.problem;
<para>
<example>
<title><function>stripos</function> examples</title>
<programlisting role="php">
<![CDATA[
<?php
$findme = 'a';
$mystring1 = 'xyz';
$mystring2 = 'ABC';
$pos1 = stripos($mystring1, $findme);
$pos2 = stripos($mystring2, $findme);
// Nope, 'a' is certainly not in 'xyz'
if ($pos1 === false) {
echo "The string '$findme' was not found in the string '$mystring1'";
}
// Note our use of ===. Simply == would not work as expected
// because the position of 'a' is the 0th (first) character.
if ($pos2 !== false) {
echo "We found '$findme' in '$mystring2' at position $pos2";
}
?>
]]>
</programlisting>
</example>
</para>
<para>
If <parameter>needle</parameter> is not a string, it is converted
to an integer and applied as the ordinal value of a character.
</para>
<para>
The optional <parameter>offset</parameter> parameter allows you
to specify which character in <parameter>haystack</parameter> to
start searching. The position returned is still relative to the
the beginning of <parameter>haystack</parameter>.
</para>
<para>
See also <function>strpos</function>, <function>strrpos</function>,
<function>strrchr</function>, <function>substr</function>,
<function>stristr</function>, <function>strstr</function> and
<function>stri_replace</function>.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->