Greetings
I would like a script which will read a PHP var and look for some certain tags and replace them to format it… some thing like this:
$originaltxt = ‘Hello! this is my picture <format type="table" name="My Picture" image="[login to view URL]" caption="I look tired" /> But I look better in real life’
The script should look for all the ‘format’ tags (or whatever is simpler), get the ‘type’, ‘name’, ‘image’ and ‘caption’ vars from each ‘format’ tag and place them something like this:
echo $originaltxt;
It displays this:
Hello! this is my picture
<table width="100%" border="0">
<tr>
<td> My Picture </td>
</tr>
<tr>
<td><img scr=”[login to view URL]”></td>
</tr>
<tr>
<td> I look tired </td>
</tr>
</table>
But I look better in real life
So this script must read all of them so I can give different formats depending on the "type" value, which I could use like this:
if ($type == 'table') {
$newformat = '<table width="100%" border="0">
<tr>
<td>'.$name.'</td>
</tr>
<tr>
<td><img scr=”'.$image.'”></td>
</tr>
<tr>
<td>'.$caption.'</td>
</tr>
</table>';
$originaltxt = str_replace($originaltxt, $newformat, $originaltxt);
}
Hi! I can do this using the php class "DOMDocument". If you choose me, I'm already working on it. I can delivery the code to you very quickly. Using "str_replace" or regex to do this job isn't a good idea.