I would like to extract the string between "t=" and '&' from the string below, but '&2384' may not be present sometimes. I have tried the following, but I get the result "123455asdfgh&2384" instead of "123455asdfgh", what am I doing wrong here? thanks for help.
$string="t=123455asdfgh&2384";
$match=array();
preg_match('/t=(.*)(&.*)?/', $string, $match);
echo $match[1];
NOTE: I need to use regular exp…
Try this one instead