By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,808 Members | 1,481 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,808 IT Pros & Developers. It's quick & easy.

list ($d, $row) = each ($array) by reference?

P: n/a
Hi !

I always thought that

while (list($d,$row) = each($array)){
$row = 5;
}

would operate by reference, so that $array is filled with 5 after
this.
Instead it only seems to work with

$array[$d] = 5;

Can I use a & somewhere to do that?

Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Jochen Daum" a écrit le 21/11/2003 :
Hi !

I always thought that

while (list($d,$row) = each($array)){
$row = 5;
}

would operate by reference, so that $array is filled with 5 after
this.
Instead it only seems to work with

$array[$d] = 5;

Can I use a & somewhere to do that?

Jochen


If you use a numeric array, consider using array_fill()
Otherwise I don't really know for an associative array and/or the by
ref method.
Jul 17 '05 #2

P: n/a
Hi Jedi!
On Fri, 21 Nov 2003 00:38:56 +0100, Jedi121
<je*********@free.fr.Removethis> wrote:
"Jochen Daum" a écrit le 21/11/2003 :
Hi !

I always thought that

while (list($d,$row) = each($array)){
$row = 5;
}

would operate by reference, so that $array is filled with 5 after
this.
Instead it only seems to work with

$array[$d] = 5;

Can I use a & somewhere to do that?

Jochen


If you use a numeric array, consider using array_fill()


It was rather for more complex things....
Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #3

P: n/a
Oh, the mystery of PHP references! I don't have an answer to your question.
In a similar situations I would array_walk, just so I don't have to think
about whether I'm getting a reference or not.

http://www.php.net/manual/en/function.array-walk.php

Uzytkownik "Jochen Daum" <jo*********@cans.co.nz> napisal w wiadomosci
news:s3********************************@4ax.com...
Hi !

I always thought that

while (list($d,$row) = each($array)){
$row = 5;
}

would operate by reference, so that $array is filled with 5 after
this.
Instead it only seems to work with

$array[$d] = 5;

Can I use a & somewhere to do that?

Jochen
--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.