Replace strings with existing ones
Posted: Sun Jun 13, 2004 5:27 pm
Alright, I'm a bit of a beginner in PHP but I'm learning pretty fast.
My problem is that:
I have a php file that includes a series of strings such as $name, $email, $score, etc. and a second one, a HTML page, which includes a website design with $name, $email, $score written all over it.
What I want to do is that every time i run the php file, it will go through the HTML page and detect every "$name" "$email" and "$score" text and replace it with the PHP file's strings of the same name... Meaning that if $name = "John" in the php file, the $name in the HTML file would be replaced by John. (Of course, the HTML file would be modified by the PHP script before being shown)
I have tried fgets and the like. I also tried to put the entire html on a single string and mangle with it but I have no clue how to make every $string from the HTML to match the ones from the php file where the HTML is opened and fgets'ed.
I'm also trying to avoid making a fopen and a fwrite ($code) with $code being tons of /" and /> if you know what I mean :S
Thanks for any help :S
My problem is that:
I have a php file that includes a series of strings such as $name, $email, $score, etc. and a second one, a HTML page, which includes a website design with $name, $email, $score written all over it.
What I want to do is that every time i run the php file, it will go through the HTML page and detect every "$name" "$email" and "$score" text and replace it with the PHP file's strings of the same name... Meaning that if $name = "John" in the php file, the $name in the HTML file would be replaced by John. (Of course, the HTML file would be modified by the PHP script before being shown)
I have tried fgets and the like. I also tried to put the entire html on a single string and mangle with it but I have no clue how to make every $string from the HTML to match the ones from the php file where the HTML is opened and fgets'ed.
I'm also trying to avoid making a fopen and a fwrite ($code) with $code being tons of /" and /> if you know what I mean :S
Thanks for any help :S