I have an array with some info. For example:
(writer) &
or
with (additional dialogue)
I want to clean this so I only get the text between the parenthesis () and clear everything else
result:
writer
or
additional dialogue
The easiest way will be with a regular expression:
preg_match_all('/\((.*?)\)/', $input, $matches);
$matches[1]
, $matches[2]
, etc will contain everything that was between parentheses in $input. That is, $matches[1]
will have whatever was between the first set of parentheses, and so on (to handle cases with multiple sets).
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