This article is mainly to share with you how PHP intercepts the specified two-character string between the methods, I hope to help everyone.
/** * php intercept specifies a string between two characters, the default character set is Utf-8 Power by Big Ear Tutu * @param string $begin Start String * @param string $end End String * @param String $str strings to intercept * @return string */function cut ($begin, $end, $str) { $b = Mb_strpos ($str, $begin) + Mb_strlen ( $begin); $e = Mb_strpos ($str, $end)-$b; Return Mb_substr ($str, $b, $e);} Call echo $this->cut (' token/', '? code ', $REDIRECTURL);d ie;
The above method is not very good, when the intercept is the value of the string, there will be no interception of the situation with the following bar
/* * PHP intercept specifies two characters between strings * */function Get_between ($input, $start, $end) { $substr = substr ($input, strlen ($start) +strpos ($input, $start), (strlen ($input)-Strpos ($input, $end)) * ( -1)); return $SUBSTR;} Call $svid = $this->get_between ($redirectUrl, "token/", "? Code=");