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??

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.

<?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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.