473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
3 2573
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Rogue9 | last post by:
Hi, I´m trying to retrieve an item from a list using a reference called ´draw´' (which is an integer from 1 to 792 in a while loop) using:- draw = 1 while 1: if draw == 792: break b1 =...
1
by: derek / nul | last post by:
Is there any list or array code that can load lines from a file? ie what I would like is to open a file and load line by line into a list or array. Any pointers most appreciated. Derek
1
by: Trev | last post by:
I can call C++ methods using byte arrays as values but I wish to call a C++ method using a reference to an empty byte array that is then initiaised to a set size by the c++ method and populated...
1
by: Hal Styli | last post by:
hello, can someone please help... Im interested in the use of an auxiliary array to act like pointers for another array, allowing the sort order to be traversed. See code below. I dont have an...
2
by: Jeff User | last post by:
I want to convert each record read (with a datareader) to a string array and then place each of those arrays into another array (sResult) The problem here is that when the inner loop begins to...
7
by: rossum | last post by:
Is there any way of creating a read only reference to an array? My class includes a private array of bytes with a Property to access it. However, I do not want users to use the returned reference...
8
by: pnsreee | last post by:
Hi all, Im trying to print ARRAY OF ARRAYS using following code. for $i (0..10) { print "\t } ] ,\n"; }
3
by: Ray D. | last post by:
Hey all, I'm trying to pass a list into a function to edit it but when I compile using g++ I continue to get the following error: maintainNeighbors.cpp:104: error: invalid initialization of...
1
by: de_ja | last post by:
HI, Thanks for assisting me with my previous query. I have almost completed my access database. And now in the process of optimising it. When I first developped the database I had...
2
by: talwar | last post by:
Hi I am having problems going through the hash reference and outputting the result. Can someone tell me how to traverse thorugh the output of "p4 info" using Perl. p4 info is a command in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.