Filtering an Array Using Regular Expressions in PHP

preg_grep
Задание 1

Given an array of strings:

php<?php
  $array = ['apple', 'banana', 'cherry', 'date', 'fig'];
?>

Filter the array, leaving only the elements starting with the letter 'b'.

Задание 2

Given an array of strings:

php<?php
  $arr = ['error404', 'success', 'warning', 'info', 'error500'];
?>

Filter the array, leaving only the strings containing the word 'error'.

Задание 3

Given an array of strings:

php<?php
  $arr = ['123', '45.6', '78', '9.0', 'text'];
?>

Filter the array, leaving only the strings representing integers.

Задание 4

Given an array of strings:

php<?php
  $arr = [
    'user1@example.com',
    'invalid',
    'user2@test.org',
    'not-email'
  ];
?>

Filter the array, leaving only valid email addresses.