What exactly is the the difference between array_map, array_walk and array_filter?

Technology CommunityCategory: PHPWhat exactly is the the difference between array_map, array_walk and array_filter?
VietMX Staff asked 4 years ago
  • array_walk takes an array and a function F and modifies it by replacing every element x with F(x).
  • array_map does the exact same thing except that instead of modifying in-place it will return a new array with the transformed elements.
  • array_filter with function F, instead of transforming the elements, will remove any elements for which F(x) is not true