What is the difference between
foreach ($my_array as $my_value) {
}
And:
foreach ($my_array as &$my_value) {
}
When you prefix a variable with an ampersand, you’re creating a “reference.” PHP references are like shortcuts or symlinks on your computer. You can create a pointer variable that is just another name for the same data.
I dont see a big difference in using these, except that you DONT COPY a variable saving memory. When you are passing variables you can just pass the reference and the reference points to the original object.