0

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

<table width="100%">
	<tr>
		<td align="center">
		<b>
			<h1 class="title_list">$$FullName$$</h1>
		</b>
		<br><br>
		</td>
 	</tr>
  	<tr>
   		<td>$$FirstName$$ is a $$Gender$$.</td>
	</tr>
</table>

How to do this??

Edited by Aamit: n/a

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by almostbob
0

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.

0
<?php
/* this file is called with url parameters ?firstname=Jon&lastname=Rama&gender=male
full_name is a concatenation of firstname lastname */
$full_name=$firstname.'_'.$lastname;
$file = $full_name.'.php';
if (file_exists($file)) { die("$file already exists"); }
$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>";
$fp = fopen($file, "x");
fputs ($fp, $text);
fclose($fp);// Close the file.
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

Edited by almostbob: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.