iconv_strpos Finds position of first occurrence of a needle within a haystack
发表日期:2021-07-01 08:55:46 | 来源: | | 浏览(1092) 分类:iconv 函数
iconv_strpos
(PHP 5, PHP 7, PHP 8)
iconv_strpos — Finds position of first occurrence of a needle within a haystack
说明
string
$haystack
,string
$needle
,int
$offset
= 0,string|null
$encoding
= null
): int|false
Finds position of first occurrence of a needle
within a haystack
.
In contrast to strpos(), the return value of
iconv_strpos() 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 encoding
.
参数
-
haystack
-
The entire string.
-
needle
-
The searched substring.
-
offset
-
The optional
offset
parameter specifies the position from which the search should be performed. If the offset is negative, it is counted from the end of the string. -
encoding
-
If
encoding
parameter is omitted ornull
,string
are assumed to be encoded in iconv.internal_encoding.
If haystack
or needle
is
not a string, it is converted to a string and applied as the ordinal
value of a character.
返回值
Returns the numeric position of the first occurrence of
needle
in haystack
.
If needle
is not found,
iconv_strpos() will return false
.
此函数可能返回布尔值
false
,但也可能返回等同于 false
的非布尔值。请阅读 布尔类型章节以获取更多信息。应使用
===
运算符来测试此函数的返回值。
更新日志
版本 | 说明 |
---|---|
8.0.0 |
encoding is nullable now.
|
7.1.0 |
Support for negative offset s has been added.
|
参见
- strpos() - 查找字符串首次出现的位置
- iconv_strrpos() - Finds the last occurrence of a needle within a haystack
- mb_strpos() - 查找字符串在另一个字符串中首次出现的位置
- PHP(0)
- PHP杂项(34)
- PHP基础-李炎恢系列课程(20)
- 中文函数手册(0)
- 错误处理 函数(13)
- OPcache 函数(6)
- PHP 选项/信息 函数(54)
- Zip 函数(10)
- Hash 函数(15)
- OpenSSL 函数(63)
- Date/Time 函数(51)
- 目录函数(9)
- Fileinfo 函数(6)
- iconv 函数(11)
- iconv_get_encoding 获取 iconv 扩展的内部配置变量(0)
- iconv_mime_decode_headers 一次性解码多个 MIME 头字段(0)
- iconv_mime_decode 解码一个MIME头字段(0)
- iconv_mime_encode Composes a MIME header field(0)
- iconv_set_encoding 为字符编码转换设定当前设置(0)
- iconv_strlen 返回字符串的字符数统计(0)
- iconv_strpos Finds position of first occurrence of a needle within a haystack(0)
- iconv_strrpos Finds the last occurrence of a needle within a haystack(0)
- iconv_substr 截取字符串的部分(0)
- iconv 字符串按要求的字符编码来转换(0)
- ob_iconv_handler 以输出缓冲处理程序转换字符编码(0)
- 文件系统函数(81)
- 多字节字符串 函数(57)
- GD 和图像处理 函数(114)
- 可交换图像信息(5)
- Math 函数(50)
- 程序执行函数(11)
- PCNTL 函数(23)
- JSON 函数(4)
- SPL 函数(15)
- URL 函数(10)
- cURL 函数(32)
- 网络 函数(33)
- FTP 函数(36)
- Session 函数(23)
- PCRE 函数(11)
- PCRE 正则语法(19)
- 数组 函数(81)
- 类/对象 函数(18)
- 函数处理 函数(13)
- 变量处理 函数(37)
- SimpleXML 函数(3)
- 杂项 函数(31)
- 字符串 函数(101)