<?php
$text = "[text]
(more text)
(text...)
[text!]
(last text)";
preg_match_all('/[\[\(](.*?)[\]\)]/', $text, $matches, PREG_SET_ORDER, 0);
$texts = array_column($matches, 1);
var_dump($texts);
- Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
- array(5) {
[0]=>
string(4) "text"
[1]=>
string(9) "more text"
[2]=>
string(7) "text..."
[3]=>
string(5) "text!"
[4]=>
string(9) "last text"
}
preferences:
153.8 ms | 404 KiB | 174 Q