What is the difference between a reference and a pointer in PHP, and how does it affect array manipulation?

In PHP, a reference is an alias to a variable, meaning that changes made to the reference will affect the original variable. On the other hand, a pointer is a variable that stores the memory address of another variable. When it comes to array manipulation, using references can lead to unexpected behavior as changes made to a reference can impact the original array, while pointers do not have this issue.

// Using pointers to avoid unexpected array manipulation
$array = [1, 2, 3];
$pointer = &$array;
$pointer[0] = 10;

print_r($array); // Output: Array ( [0] => 10 [1] => 2 [2] => 3 )