|
Posted by Ivαn Sαnchez Ortega on 12/28/07 22:02
mantrid wrote:
> I looked at the manual. and it does look like its due to my version of
> php. Seems using & to modify array's elements is only available in version
> 5. What should I do?
First, upgrade to PHP5 ;-)
(Remember that PHP4's end-of-life is near, BTW)
Second, modify the array elements by using the array name and the relevant
key:
Instead of
foreach ($array as $key=>&$item)
{
$item['foo'] = $whatever;
}
use something like:
foreach ($array as $key=>$item)
{
$array['key']['foo'] = $whatever;
}
*And* leave a nice comment about changing that when upgrading to PHP5. Don't
forget about those little things, try to keep your code clean.
> ps I will look for the answer in the meantime myself, so you dont think Im
> lazy. But its all starting to look complicated with this referencing stuff
Referencing stuff is not that complicated (it gets very easy if you know are
trained in C pointers), but it's pretty good to handle situations like
this, and it's indispensable if you want to do semi-complex stuff with
classes and objects.
--
----------------------------------
IvΓ‘n SΓ‘nchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
To be or not to be.
-- Shakespeare
To do is to be.
-- Nietzsche
To be is to do.
-- Sartre
Do be do be do.
-- Sinatra
Navigation:
[Reply to this message]
|