Page 1 of 1

Search string and convert to html tags

Posted: Tue Nov 04, 2008 7:26 pm
by cmora
Hi to all. I have a problem that can any one pls help me. i want to build a php code the get the string and convert it into html tags sample : [a.param=value]go to[a] to be converted to <a href="test.php?param=value">go to</a> . My problem is how may i get the "[a.param=value]go to[a]" and what if it has many strings like this to be converted.. Please if has any one has a idea help me :D

thanks in advance

Re: Search string and convert to html tags

Posted: Tue Nov 04, 2008 8:15 pm
by requinix
For that specific template

Code: Select all

preg_replace('/\[a\.([^=]+)=([^\]]+)\](.*?)\[a\]/i', '<a href="test.php?\1=\2">\3</a>', $string);
If it isn't what you want, give more examples or a more detailed explanation.