Search string and convert to html tags

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cmora
Forum Newbie
Posts: 1
Joined: Tue Nov 04, 2008 7:13 pm

Search string and convert to html tags

Post 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
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Search string and convert to html tags

Post 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.
Post Reply