$re = '/Samsung(?=.*?Galaxy S)/mi';
$str = '$data =
Array
(
[0] => Array
(
[name] => Samsung GT-N7100 Galaxy Note II 16GB
)
[1] => Array
(
[name] => Samsung GT-i9100 Galaxy S II
)
[2] => Array
(
[name] => Samsung GT-i9300 Galaxy S III 16GB
)
[3] => Array
(
[name] => Apple iPhone 5 16GB
)
[4] => Array
(
[name] => Samsung GT-P5110 Galaxy S 4 10.1 16GB
)
[5] => Array
(
[name] => Samsung UE46ES6715
)
[6] => Array
(
[name] => Samsung 830 Series MZ-7PC128 128GB
)
[7] => Array
(
[name] => Samsung GT-N8000 Galaxy Note 10.1 16GB
)
[8] => Array
(
[name] => Samsung 830 Series MZ-7PC256 256GB
)
[9] => Array
(
[name] => Samsung UE46ES6715
)
[10] => Array
(
[name] => Samsung GT-2423 Galaxy Tab 4 10.1 16GB
)';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php