943,572 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 324
  • PHP RSS
Sep 25th, 2009
0

Repalce content in html??

Expand Post »
Hi,This is my php file.
I want to replace
$$FullName$$ with Jon Rama
And $$FirstName$$ with Jon and $$Gender$$ with Male


And create to new file Jon_Rama.php

PHP Syntax (Toggle Plain Text)
  1. <table width="100%">
  2. <tr>
  3. <td align="center">
  4. <b>
  5. <h1 class="title_list">$$FullName$$</h1>
  6. </b>
  7. <br><br>
  8. </td>
  9. </tr>
  10. <tr>
  11. <td>$$FirstName$$ is a $$Gender$$.</td>
  12. </tr>
  13. </table>

How to do this??
Last edited by Aamit; Sep 25th, 2009 at 5:39 pm.
Similar Threads
Reputation Points: 3
Solved Threads: 15
Posting Whiz
Aamit is offline Offline
341 posts
since Apr 2008
Sep 25th, 2009
0

Re: Repalce content in html??

If you are trying the process the code as data then you will probably want to use file_get_contents and file_put_contents to read and write the php file as if it were data.

You will then probably want a table of fields to check for and then scan the string read from the file and do a search and replace (str_replace) to substitute the new values.
Reputation Points: 210
Solved Threads: 228
Nearly a Posting Virtuoso
chrishea is offline Offline
1,389 posts
since Sep 2008
Sep 26th, 2009
0

Re: Repalce content in html??

php Syntax (Toggle Plain Text)
  1. <?php
  2. /* this file is called with url parameters ?firstname=Jon&lastname=Rama&gender=male
  3. full_name is a concatenation of firstname lastname */
  4. $full_name=$firstname.'_'.$lastname;
  5. $file = $full_name.'.php';
  6. if (file_exists($file)) { die("$file already exists"); }
  7. $text="<table width='100%'><tr><td align='center'><b><h1 class='title_list'>$firstname $lastname</h1></td></tr><tr><td>$firstname is a $gender.</td></tr></table>";
  8. $fp = fopen($file, "x");
  9. fputs ($fp, $text);
  10. fclose($fp);// Close the file.
  11. echo $file.' created'; ?>
If the data comes from an sql table the rows can be stepped through
If the data comes from a form the $_post array can be mined for data
Last edited by almostbob; Sep 26th, 2009 at 1:33 am.
Reputation Points: 562
Solved Threads: 367
Posting Maven
almostbob is online now Online
2,970 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Problem usin <?PhP tag
Next Thread in PHP Forum Timeline: Attachment file corrupted in Email





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC