您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

在PHP中检查一个字符串是否以给定的单词开头

2024/2/20 0:48:39发布15次查看
create a function to check whether a string begins with the specified string or not. the function should return true on success or false on failure.
the following is the syntax −
begnwith(str, begnstr)
consider the following parameters in it to check −
str − the string to be tested
begnstr − the text to be searched in the beginning of the specified string.
examplethe following is an example −
live demo
<?php function begnwith($str, $begnstring) { $len = strlen($begnstring); return (substr($str, 0, $len) = = = $begnstring); } if(begnwith("pqrstuvwxyz","p")) echo "true! it begins with p!"; else echo "false! it isn't beginning with p!";?>
输出以下是输出 −
true! it begins with p!
以上就是在php中检查一个字符串是否以给定的单词开头的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product