$var = 'Click on this <a href="#">link</a>. (goes to heaven) (and then somewhere else)';
How to get the text, which is placed between first brackets?
Throw its value to $extra
In this example $extra = 'goes to heaven'
Thanks.
$var = 'Click on this <a href="#">link</a>. (goes to heaven) (and then somewhere else)';
How to get the text, which is placed between first brackets?
Throw its value to $extra
In this example $extra = 'goes to heaven'
Thanks.
preg_match("/\\((.+?)\\)/", $var, $matches);
$extra = $matches[1];
This is strictly true for the example you provided. If you are parsing arbitrary HTML, you'll have to use DOMDocument
or similar instead.