input: Write a function to filter an array by a given criteria and return the filtered array. The function should accept an array and a criteria function as parameters, iterate through the array, check if each element matches the criteria, and add the matching elements to a new list which is then returned. The criteria function should be provided by the user.
  
  def filter_array(array, criteria):
      filtered_array = []
      for value in array:
          if criteria(value):
              filtered_array.append(value)
      return filtered_array
  
  def criteria(x):
      return x % 5 == 0
  
  array = [1, 2, 5, 10, 15, 20, 25, 30]
  result = filter_array(array, criteria)
  assert result == [5, 10, 15, 20, 25, 30]
output: def filter_array(array, criteria):
      filtered_array = []
      for value in array:
          if criteria(value):
              filtered_array.append(value)
      return filtered_array