php-doc-en/reference/mbstring/functions/mb-strpos.xml
Kim Hallberg f63aa0afcd
[80738] Update MB string functions (#630)
* Add new `mbstring.changelog.needle-empty` entity

* Update changelog with `mbstring.changelog.needle-empty` entity
The following functions now support an empty `needle` argument.

- mb_strpos
- mb_strrpos
- mb_stripos
- mb_strripos
- mb_strstr
- mb_stristr
- mb_strrchr
- mb_strrichr
2021-09-17 20:53:19 +01:00

134 lines
3.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.mb-strpos" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>mb_strpos</refname>
<refpurpose>Find position of first occurrence of string in a string</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>int</type><type>false</type></type><methodname>mb_strpos</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><initializer>0</initializer></methodparam>
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>encoding</parameter><initializer>&null;</initializer></methodparam>
</methodsynopsis>
<para>
Finds position of the first occurrence of a <type>string</type> in a <type>string</type>.
</para>
<para>
Performs a multi-byte safe
<function>strpos</function> operation based on number of
characters. The first character's position is 0, the second character
position is 1, and so on.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>haystack</parameter></term>
<listitem>
<para>
The <type>string</type> being checked.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>needle</parameter></term>
<listitem>
<para>
The string to find in <parameter>haystack</parameter>. In contrast
with <function>strpos</function>, numeric values are not applied
as the ordinal value of a character.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>offset</parameter></term>
<listitem>
<para>
The search offset. If it is not specified, 0 is used.
A negative offset counts from the end of the string.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>encoding</parameter></term>
<listitem>
&mbstring.encoding.parameter;
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the numeric position of
the first occurrence of <parameter>needle</parameter> in the
<parameter>haystack</parameter> <type>string</type>. If
<parameter>needle</parameter> is not found, it returns &false;.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
&mbstring.changelog.needle-empty;
&mbstring.changelog.encoding-nullable;
<row>
<entry>7.1.0</entry>
<entry>
Support for negative <parameter>offset</parameter>s has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mb_internal_encoding</function></member>
<member><function>strpos</function></member>
</simplelist>
</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:"~/.phpdoc/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
-->