Re: Re: argument variable gets lost in function

From: Date: Thu, 25 Oct 2001 15:13:29 +0000
Subject: Re: Re: argument variable gets lost in function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-72285@lists.php.net to get a copy of this message
> > hmm...weird! is that the code? > if you show us your real code...maybe you're missing a small detail... > Sorry about the variable names... I can print the variable inside the function until it goes through ereg_replace. Then it's gone. The code works fine if I replace the line '$song = $id3info["TIT2"]["data"];' with '$song = "some text string";' Since it's getting the variables value from an included file's functions that return and assoc. array... it's a bit confusing. I everything is fine up till the built-in function (inside my function) is called. Weird is right... <?php include("getid3.php"); function RemoveSpaces($shittoreplace) { // Removes spaces and other characters that could cause problems. $shittoreplace = ereg_replace(" ", "_", "$shittoreplace"); return $shittoreplace; } $id3info = (getID3("music.mp3")); $song = $id3info["TIT2"]["data"]; $newsong = RemoveSpaces("$song"); echo "$newsong"; ?> >> I'm assigning a variable a value from an associative array. >> $variable = $array["key"]["value"]; >> >> Then passing the $variable to a function. >> SomeFunction($variable) >> >> The variable exists (can be printed) until a built-in function (within the >> original function) is called. >> echo "$variable"; //prints out fine >> $variable2 = ereg_replace(" ", "_", "$variable"); >> echo "$variable"; //prints out NOTHING... >> >> Why is this and how can I get around it?

« previous php.general (#72285) next »