I am trying to get the ID from transaction(123456) in the HTML
It doesn’t seem to return anything.
$response = "</body> </html><script type='text/javascript'>transaction(123456);</script>";
preg_match('/^transaction\((\d+)\)/', $response, $match);
print_r($match);
if (is_numeric($match[1])) {
echo "Your ID: " . $match[1];
}
Because you have the start of string anchor
^, andtransaction(isn’t at the start of the string. Remove that (or add a non-greedy match) and it’ll work (as shown by this demo):