PHP Capture tool: Capture the required collection data based on the start string and end string
Function Strcutbystr (& $str, $findStart, $findEnd = false, $encoding = ' utf-8 ') {if (Is_array ($findStart)) { if (count ($findStart) = = = Count ($findEnd)) {foreach ($findStart as $k = = $v) {if ( ($result = Strcutbystr ($str, $v, $findEnd [$k], $encoding)) (!==) {return $result; }} return false; }else{return false; }} if (($start = Mb_strpos ($str, $findStart, 0, $encoding)) = = = = False) {return false; } $start + = Mb_strlen ($findStart, $encoding); if ($findEnd = = = False) {return Mb_substr ($str, $start, NULL, $encoding); if ($length = Mb_strpos ($str, $findEnd, $start, $encoding)) = = = = False) {return false; } return Mb_substr ($str, $start, $length-$start, $encoding); }
Example:
$str = ' 1 That's a 23 I asked 4567890 dimensional stability '; Echo (Strcutbystr ($str, ' That's ', ' steady '));//Output A 23 I'll ask 4567890.
PHP Capture tool: Capture the required collection data based on the start string and end string