What are some potential pitfalls when using array_walk in PHP?
One potential pitfall when using array_walk in PHP is that the callback function may unintentionally modify the array elements directly, leading to unexpected results. To avoid this, it's important to pass the array element by reference in the callback function using the '&' symbol. Example:
```php
$array = [1, 2, 3, 4, 5];
function addOne(&$value) {
$value += 1;
}
array_walk($array, 'addOne');
print_r($array);
```
This code snippet demonstrates how to use the '&' symbol to pass the array element by reference in the callback function, ensuring that the array elements are modified as intended.