- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$subject = "text text text text [helloo] text [hello2] (hello3) text";
$pattern = '/\[(.+?)\]/is';
$matched = preg_match($pattern, $subject, $matches);
print_r($matches);
print_r($matched);