<?php
function find_all_phrases($string) {
$start = 0;
while (($start = strpos($string, "[", $start)) !== false &&
($end = strpos($string, "]", $start)) !== false) {
if ($end - $start > 1) $positions[] = [$start, $end];
$start = $end++;
}
return $positions;
}
print_r(find_all_phrases("[1] [25] [99] [2521] []lorem [2]"));