Is there a PHP function that grabs the string in between two characters. For example, I want to know what is between the percent and dollar symbol:
%HERE$
What is the function for this?
You could do that with a regex :
$string = 'test%HERE$glop';
$m = array();
if (preg_match('/%(.*?)\$/', $string, $m)) {
var_dump($m[1]);
}
Will get you :
string 'HERE' (length=4)
Couple of notes :
$ in the pattern has the be escaped, as it has a special meaning (end of string).*
% and $.*?() arround it.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With