Hi, Tuesday, January 14, 2003, 11:01:33 AM, you wrote: P> -----BEGIN PGP SIGNED MESSAGE----- P> Hash: SHA1
P> On Monday 13 January 2003 20:01, Tom Rogers wrote: >> Hi, >> >> Tuesday, January 14, 2003, 9:36:57 AM, you wrote: >> P> -----BEGIN PGP SIGNED MESSAGE----- >> P> Hash: SHA1 >> >> P> I did a complex class that works with XML parsing and complex structured >> where P> I used references extensivly and now I'm surprised with: >> >> P> Warning: Call-time pass-by-reference has been deprecated - argument >> passed by P> value; If you would like to pass it by reference, modify the >> declaration of P> array_push(). If you would like to enable call-time >> pass-by-reference, you P> can set allow_call_time_pass_reference to true in >> your INI file. However, P> future versions may not support this any longer. >> >> P> I can't modify the php.ini since I'm in a shared but the problem is >> deeper. P> Why was it deprecated ? what replaced it ? is there any work >> arround ? P> My 200 lines of code without references could take much, much >> longer and be P> much, much more messy. >> P> Any ideas ? >> P> Thanks. >> P> - -- >> P> Pupeno: [EMAIL PROTECTED] >> P> http://www.pupeno.com >> P> - --- >> P> Help the hungry children of Argentina, >> P> please go to (and make it your homepage): >> P> http://www.porloschicos.com/servlet/PorLosChicos?comando=donar >> P> -----BEGIN PGP SIGNATURE----- >> P> Version: GnuPG v1.0.7 (GNU/Linux) >> >> P> iD8DBQE+I02cLr8z5XzmSDQRAs/0AKCyf+UG0uZdbwG30WFU0UUNVWO7BwCgnCn5 >> P> 2LmOOJi8uX+1dOqUfCTatSE= >> P> =5obN >> P> -----END PGP SIGNATURE----- >> >> I am sure array_push accepts the array as a reference so there is no need >> to use the & operator in the call. At least thats how it works in a simple >> class..... P> No, I mean, what you're pushing inside the array is a reference: P> array_push($anArrayOfReferences, &$thisIsAVariable); P> that doesn't work, but I replaced by P> $anArrayOfReferences[count($anArrayOfReferences)] = &$thisIsAVariable; P> Thanks :) Ok :) These 2 functions will do what you want I think... function array_ref_push(&$array,&$ref){ $array[] =& $ref; } function &array_ref_pop(&$array){ $r =& $array[count($array)-1]; array_pop($array); //throw away a real pop return $r; } //Testing $stack = array(); $var = 1; array_ref_push($stack,$var); echo '<pre>'; print_r($stack); echo '</pre>'; $var = 2; echo '<pre>'; print_r($stack); echo '</pre>'; $var2 =& array_ref_pop($stack); echo 'var2 = '.$var2.'<br>'; $var = 3; echo 'var2 = '.$var2.'<br>'; echo '<pre>'; print_r($stack); echo '</pre>'; -- regards, Tom -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php