View Single Post
Old 03-31-2009, 06:41 PM   #4 (permalink)
Salathe
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

With regards to the original post, your use of $GLOBALS was incorrect. The correction would be unset($GLOBALS['myArray'][$i]);

Quote:
Originally Posted by xenon
Well...that's not good. I don't know who told you this, but it's completely wrong. The reason is not found in the code, hower, but in the PHP engine itself.
The reason is found in the code, not the PHP engine. Passing the array by reference or value is not really the key point; the problem was accessing the correct structure in the $GLOBALS array.

However, it would probably be more beneficial to start over and work with a reference to the array within the function as it would alleviate the need to have the global variable always named $myArray.

The warnings about call-time pass-by-reference being deprecated are only raised when you try to pass an argument as a reference when calling a function (e.g. $blah = myfunc(&$array)) and not when defining a function as accepting arguments by reference (e.g. function myfunc(&$array)).
Salathe is offline  
Reply With Quote