- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$subject = "text text text text [hello] text (hello2) (hello3) text";
$pattern = '/^\[([^)]*)\]/';
preg_match($pattern, $subject, $matches, PREG_OFFSET_CAPTURE, 3);
print_r($matches);