- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$s = '[a]какой-то
текст[/a] еще куча какого то текста, [a]какого-то текста
[/a]';
if (preg_match_all('~\[a].*?\[/a]~s', $s, $matches)) {
print_r($matches[0]);
}
echo "\n";
if (preg_match_all('~\[a](.*?)\[/a]~s', $s, $matches)) {
print_r($matches[1]);
}