允许双点范围语法的天然PHP函数
某些本机PHP字符串函数具有一个参数,该参数是一个或多个无序字符的字符串(也称为“字符掩码”)。在某些情况下,角色范围可以使用双点语法表示。
例如: echo trim('foo24','0..9');
prints foo
因为 2
和 4 属于
0
通过 9
范围。
其他具有相同功能的本机PHP字符串功能是什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尊重双点范围表达式的本机php字符串函数:
addcslashes()
( demo < /a>)chop> chop() -
rtrim()
的别名( demo )ltrim()
( demo )rtrim()( demo )
str_word_count()代码>( demo )
trim()( demo )
ucwords(ucwords()代码>( demo )
这是一些本机函数,其中不展开范围的表达式,但可能是该功能的合理候选人:
strcspn()
( demo )(扩展是合理的)strpbrk()
( demo )(扩展是合理的)strspn()
( demo )(扩展是合理的)strtok()
( demo )(扩展是合理的)strtr()
( demo )(不在主题范围之外,因为从技术上讲不是字符面具 - 字符顺序很重要)由于支持
的技术挑战。
..
参考: https://wiki.php.net/ rfc/mb_trim
mb_ltrim()
mb_rtrim()
mb_trim()
Native PHP string functions that respect double-dot range expressions:
addcslashes()
(Demo)chop()
-- alias ofrtrim()
(Demo)ltrim()
(Demo)rtrim()
(Demo)str_word_count()
(Demo)trim()
(Demo)ucwords()
(Demo)Here are some native functions where ranged expressions are not expanded, but might be reasonable candidates for the feature:
strcspn()
(Demo) (expansion would be reasonable)strpbrk()
(Demo) (expansion would be reasonable)strspn()
(Demo) (expansion would be reasonable)strtok()
(Demo) (expansion would be reasonable)strtr()
(Demo) (out of topic scope because not technically a character mask -- character order matters)Due to technical challenges of supporting
..
syntax with multibyte characters, the following native functions will not allow..
Ref: https://wiki.php.net/rfc/mb_trim
mb_ltrim()
mb_rtrim()
mb_trim()