What are the potential pitfalls of using for loops to manipulate arrays in PHP, as seen in the provided code snippet?

Using for loops to manipulate arrays in PHP can be error-prone and tedious, as it requires manually managing the array indexes and lengths. This can lead to off-by-one errors or unintended side effects. Instead, using built-in array functions like `array_map` or `array_walk` can simplify the code and reduce the chances of errors.

// Fix using array_map to manipulate array elements
$numbers = [1, 2, 3, 4, 5];

$modifiedNumbers = array_map(function($num) {
    return $num * 2;
}, $numbers);

print_r($modifiedNumbers);