Get your own PHP server Result Size: 625 x 565
x
 
<!DOCTYPE html>
<html>
<body>
<?php
$input = [
  "Red",
  "Pink",
  "Green",
  "Blue",
  "Purple"
];
$result = preg_grep("/^p/i", $input);
print_r($result);
?>
</body>
</html>
Array
(
    [1] => Pink
    [4] => Purple
)