Re: variable gets lost in function problem again...

From: Date: Fri, 26 Oct 2001 09:16:11 +0000
Subject: Re: variable gets lost in function problem again...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72421@lists.php.net to get a copy of this message
> I have an two dimensional array that is returned from code from an included > file. I'm assigning parts of the array to variables ( $variable = > $array["key"]["value"]; ). This works fine and can be printed until I send > it through a function eg. ( ereg_replace(" ", "_", "$variable"); > ). After > this, $variable is blank. > > I don't think it's my code because substituting a text string for the array > data (eg. $variable = "this is some text";) works just fine. > > It has something to do with the assigning array data to a variable or > perhaps that the data comes from an included file... This could be a bug in > PHP? Spunk Could you post some excerpted code please? You seem to have multiple issues: 1 communication between a 'mainline' and INCLUDEd code 2 communication between a 'mainline' and a function 3 working with scalars and arrays 4 working with text strings and ?text arrays - which may or may not be related/relevant Let's start with simple ideas: 0 put debug echo statements into the function (or everywhere) to track progress 1 if you take the processing code out of the INCLUDE file and put it in the 'mainline', does it then work as planned? 2 do you have an & to indicate a pass by reference cf a pass by value (see manual)? 3 and 4 does the processing use tools/approach/functions that only work with scalars/arrays/strings? A process of elimination... Keep us posted, =dn

« previous php.general (#72421) next »