Ok, well... While that was just an example.. In my real code, I'm attempting to pass 2 arrays by reference, and the function I'm passing to is in an include file. Is passing my reference something that is commonly done in PHP or do most developers use globals? I'm just trying to be as efficient as possible. :-) Thanks, Jim -----Original Message----- From: ????????? ??????? [mailto:silya@xxxxxxxxxxx] Sent: Tuesday, August 10, 2004 11:10 AM To: Jim MacDiarmid Subject: Re: FW: Passing arrays by reference Здравствуйте, Jim. Вы писали 10 августа 2004 г., 16:05:19: JM> Thanks, That seems to have worked. Now, can you or someone tell me JM> why I can't seem to get it to work when I separate the function implementation JM> from the calling statemtent? For instance: JM> Say I have the following function in file called "My_Function_Includes.php": JM> <?php JM> function foo(&$a) JM> { JM> for ($i=0; $i < 10; $i++) JM> { JM> $a[$i] = $i; JM> } JM> } ?>> JM> In my index.php I have: JM> <?php JM> Include_once('My_Function_Includes.php'); JM> $a = array(); JM> foo($a); JM> echo "<PRE>"; JM> print_r($a); JM> echo "</PRE>"; ?>> JM> This example doesn't seem to work however, when I paste the function JM> implementation into the index.php and run it, it works. JM> Thanks for any help in advance, JM> Jim JM> -----Original Message----- JM> From: Justin Patrin [mailto:papercrane@xxxxxxxxx] JM> Sent: Monday, August 09, 2004 5:52 PM JM> To: Jim MacDiarmid JM> Cc: php-windows@xxxxxxxxxxxxx JM> Subject: Re: Passing arrays by reference JM> On Mon, 9 Aug 2004 17:28:40 -0400, Jim MacDiarmid JM> <jim.macdiarmid@xxxxxxxxxxx> wrote: >> >> Hi everyone, >> >> I've seen several examples of passing arrays by reference such as the >> following: >> >> $a = array(); >> >> function foo(&a) JM> function foo(&$a) >> { >> for ($i=0; $i < 10; i++) >> { >> $a[$i] = $i; >> } >> } >> >> foo($a); >> echo "<PRE>"; >> print_r($a); >> echo "</PRE>"; >> >> However, when I try this on my setup, it doesn't work and I get the >> following error message: >> >> PHP Parse error: parse error, unexpected T_STRING, expecting >> T_VARIABLE in... >> >> Anyone have any ideas or suggestions? >> >> Thanks, >> Jim >> >> -- >> PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: >> http://www.php.net/unsub.php >> JM> -- JM> DB_DataObject_FormBuilder - The database at your fingertips JM> http://pear.php.net/package/DB_DataObject_FormBuilder JM> paperCrane --Justin Patrin-- JM> -- JM> PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: JM> http://www.php.net/unsub.php Try to use <? function foo() {... return $a; ... } $a = array(); $a = foo(); ?> or use $_GLOBALS array in your function, but to my mind it is not good idea -- С уважением, Александр mailto:silya@xxxxxxxxxxx -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php