strstr

(PHP 4, PHP 5, PHP 7)

strstr锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟阶次筹拷锟斤拷

说锟斤拷

strstr ( string $haystack , mixed $needle [, bool $before_needle = FALSE ] ) : string

锟斤拷锟斤拷 haystack 锟街凤拷锟斤拷锟斤拷 needle 锟斤拷一锟轿筹拷锟街碉拷位锟矫匡拷始锟斤拷 haystack 锟斤拷尾锟斤拷锟街凤拷锟斤拷锟斤拷

Note:

锟矫猴拷锟斤拷锟斤拷锟街达拷小写锟斤拷锟斤拷锟斤拷锟揭拷锟斤拷锟斤拷执锟叫⌒达拷锟斤拷锟绞癸拷锟� stristr()锟斤拷

Note:

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷确锟斤拷 needle 锟角凤拷锟斤拷锟斤拷锟� haystack 锟叫o拷锟斤拷使锟斤拷锟劫度革拷锟届、锟侥凤拷锟节达拷锟斤拷俚锟� strpos() 锟斤拷锟斤拷锟斤拷

锟斤拷锟斤拷

haystack

锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷

needle

锟斤拷锟� needle 锟斤拷锟斤拷一锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷么锟斤拷锟斤拷锟斤拷转锟斤拷为锟斤拷锟酵诧拷锟斤拷锟斤拷为锟街凤拷锟斤拷锟斤拷锟斤拷锟绞癸拷谩锟�

before_needle

锟斤拷为 TRUE锟斤拷strstr() 锟斤拷锟斤拷锟斤拷 needle 锟斤拷 haystack 锟叫碉拷位锟斤拷之前锟侥诧拷锟街★拷

锟斤拷锟斤拷值

锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷一锟斤拷锟街伙拷锟斤拷 FALSE锟斤拷锟斤拷锟轿达拷锟斤拷锟� needle锟斤拷锟斤拷

锟斤拷锟斤拷锟斤拷志

锟芥本 说锟斤拷
5.3.0 锟斤拷锟斤拷锟斤拷选锟斤拷 before_needle 锟斤拷锟斤拷锟斤拷
4.3.0 strstr() 锟斤拷为锟斤拷锟斤拷锟狡帮拷全锟侥★拷

锟斤拷锟斤拷

Example #1 strstr() 锟斤拷锟斤拷

<?php
$email  
'name@example.com';
$domain strstr($email'@');
echo 
$domain// 锟斤拷印 @example.com

$user strstr($email'@'true); // 锟斤拷 PHP 5.3.0 锟斤拷
echo $user// 锟斤拷印 name
?>

锟轿硷拷

  • preg_match() - 执锟斤拷匹锟斤拷锟斤拷锟斤拷锟斤拷式
  • stristr() - strstr 锟斤拷锟斤拷锟侥猴拷锟皆达拷小写锟芥本
  • strpos() - 锟斤拷锟斤拷锟街凤拷锟斤拷锟阶次筹拷锟街碉拷位锟斤拷
  • strrchr() - 锟斤拷锟斤拷指锟斤拷锟街凤拷锟斤拷锟街凤拷锟斤拷锟叫碉拷锟斤拷锟揭伙拷纬锟斤拷锟�
  • substr() - 锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟接达拷