导航首页 »  技术教程 »  PHP字符串函数strpbrk()的用法
PHP字符串函数strpbrk()的用法 1065 2023-12-12   

strpbrk

(PHP 5)

strpbrk — 在字符串中查找一组字符的任何一个字符

说明

string strpbrk ( string $haystack , string $char_list )

strpbrk() 函数在 haystack 字符串中查找 char_list 中的字符。

参数

haystack

在此字符串中查找 char_list

char_list

该参数区分大小写。

返回值

返回一个以找到的字符开始的子字符串。如果没有找到,则返回 FALSE

范例

Example #1 strpbrk() 范例

<?php

$text = 'This is a Simple text.';

// 输出 "is is a Simple text.",因为 'i' 先被匹配
echo strpbrk($text, 'mi');

// 输出 "Simple text.",因为字符区分大小写
echo strpbrk($text, 'S');
?>

参见

strpos() - 查找字符串首次出现的位置 strstr() - 查找字符串的首次出现 preg_match() - 执行一个正则表达式匹配



文章评论 (0条)
发表评论
暂无评论,快来抢沙发吧~