1. 程式人生 > >php擷取字串中間的字串(設定開頭和結尾)

php擷取字串中間的字串(設定開頭和結尾)

例如:我們要獲取:EE20181017143211468888

$result = '積分商城扣除積分 1訂單號: EE20181017143211468888 OPENID: sns_wa_o_L7W5R4HWpw1kY5DXjzsdu9eCSc';
$bb = strpos($result,"訂單號: ",0);
$cc = strpos($result," OPENID",0);
$dd =  substr($result,$bb+11,$cc-$bb-11);
var_dump($dd);