Re: Stating Variables in external .txt files

From: Date: Thu, 24 Aug 2000 00:36:37 +0000
Subject: Re: Stating Variables in external .txt files
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-13270@lists.php.net to get a copy of this message
At 09:57 AM 8/24/2000 +0930, scott wrote:
I am reading in text files and setting them as the variable $newsItem --- $newsItem = fread($text, 100); --- So it is just reading up to 100 chars of the file. But if I inlcude for example --- $foo = "BAR"; --- then PHP wont recognize this as its own var, but rather just a string in $newsItem (which changes value each loop). Is there anyway I can read in a .txt file and state something like --- $foo = "BAR"; --- and have PHP interpret that as a variable. Hope So. Thanks for anyhelp. Scott.
Hi Scott, If I understood what you say, you want to parse a text file and check for "variables" inside them, like if you were parsing a php file and checking for any variables being set inside its code. You want to check for anything like ' $boo = "blah"; ' inside your text file and create a dynamic variable for this and set the correct value. Is that it ? You can just check for the string "$" followed by any other string, with a equal sign after it, a value after the equal sign, and then the value, not forgetting the semi-colon. You can use regular expressions to do this, but I'm not that good to give it to you. Try taking a look at http://www.php.net/manual/ on the regular expression functions. Anyway, why do you want to do something like this ? Regards, Joao -- Joao Prado Maia Web Developer Kefta.com, Inc

« previous php.general (#13270) next »