Q:

Extract ID's from string

I have multiple strings like this :

[13] Glass with digitizer (iPhone 5), [106] Battery (iPad 4), [192]
  2GB DDR3 1067 MHz (Memory)

And I don't know how can I simple extract ID's from string to array?

A:

You can try with:
$input  = '[13] Glass with digitizer (iPhone 5), [106] Battery (iPad 4), [192] 2GB DDR3 1067 MHz (Memory)';
preg_match_all('/\[(\d+)\]/', $input, $matches);
$output = array_map('intval', $matches[1]);

Output:
array (size=3)
  0 => int 13
  1 => int 106
  2 => int 192

