(PHP 4, PHP 5, PHP 7)
strcspn — 锟斤拷取锟斤拷匹锟斤拷锟斤拷锟街碉拷锟斤拷始锟斤拷锟街凤拷锟斤拷锟侥筹拷锟斤拷
$str1
, string $str2
[, int $start
[, int $length
]] ) : int
锟斤拷锟斤拷 str1
锟叫o拷锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 str2
锟斤拷围锟斤拷锟斤拷始锟斤拷锟街凤拷锟斤拷锟侥筹拷锟饺★拷
str1
锟斤拷一锟斤拷锟街凤拷锟斤拷锟斤拷
str2
锟节讹拷锟斤拷锟街凤拷锟斤拷锟斤拷
start
锟斤拷锟揭碉拷锟斤拷始位锟矫★拷
length
锟斤拷锟揭的筹拷锟饺★拷
锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟接达拷锟侥筹拷锟饺★拷
Example #1 strcspn() example
<?php
$a = strcspn('abcd', 'apple');
$b = strcspn('abcd', 'banana');
$c = strcspn('hello', 'l');
$d = strcspn('hello', 'world');
var_dump($a);
var_dump($b);
var_dump($c);
var_dump($d);
?>
锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�
int(0) int(0) int(2) int(2)
Note: 锟剿猴拷锟斤拷锟缴帮拷全锟斤拷锟节讹拷锟斤拷锟狡讹拷锟斤拷