Re: Pass Array parameter by reference
| From: | Tom Rogers | Date: | Thu, 20 Feb 2003 13:19:15 +0000 |
| Subject: | Re: Pass Array parameter by reference | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136345@lists.php.net to get a copy of this message | ||
Hi,
Thursday, February 20, 2003, 10:52:11 PM, you wrote:
A> Hi!
A> How can I pass an array parameter by reference?
A> I tried something similar:
A> function my_function($argument) {
A> $argument[0]="test";
A> }
A> my_function(&$array);
A> echo $array[0];
A> but the echo function returns "Array".
A> Can anybody help me?
A> Thanks!
A> Andrea
Try like this
my_function(&$argument){
$argument[0] = 'test';
}
$array = array();
my_function($array);
echo $array[0];
The function declaration is what determins the reference passing.
--
regards,
Tom