This question already has an answer here:
- Extract numbers from a string 20 answers
I have this string
@[181] @[183] @[4563]
from this string I want to get values between [] in this case
181,183,4563
</div>
This question already has an answer here:
I have this string
@[181] @[183] @[4563]
from this string I want to get values between [] in this case
181,183,4563
</div>
This should do the trick:
$string = '@[181] @[183] @[4563]';
preg_match_all('/\[([0-9]*)\]/', $string, $matches);
foreach($matches[1] as $number) {
echo $number;
}