PHP 代码:【复制】function inContent($str,$start,$end,$add = true) { $first = strstr($str,$start); if ($first == false) { return array(); } else { $first = substr($first,strlen($start)); } $second = strstr($first,$end); if ($second == false) { if ($add) { return array($start.$first); } else { return array($first); } } $final = substr($first,0,-strlen($second)); if ($add) { $final = $start.$final.$end; } $result[] = $final; $second = substr($second,strlen($end)); if (strstr($second,$start)) { $result = array_merge($result,inContent(substr($second,strlen($end)),$start,$end,$add)); } return $result; }