Avatar ·

What is the difference between array_map, array_walk and array_filter in PHP?

Hi everyone! I just started learning PHP and I can't figure out the difference between array_map, array_walk and array_filter functions. They all seem to accept a callback and apply it to an array. But when I try to use them in real code, the results are different or I just don't understand which one to choose.\n\nFor example, I have an array of numbers:\n```php\n$numbers = [1, 2, 3, 4, 5];\n```\n\nI want to:\n1. Multiply each number by 2.\n2. Output each number with the prefix "Number: ".\n3. Filter only even numbers.\n\nI tried array_map:\n```php\n$doubled = array_map(function($n) { return $n * 2; }, $numbers);\n```\nIt seems to work, returns a new array. But can array_walk also be used? Or array_filter?\n\nI tried array_walk:\n```php\narray_walk($numbers, function(&$n) {