FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » preg_replace... I can't do it!!
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: preg_replace... I can't do it!! [message #180540 is a reply to message #180511] Mon, 25 February 2013 10:43 Go to previous message
Captain Paralytic is currently offline  Captain Paralytic
Messages: 204
Registered: September 2010
Karma:
Senior Member
On Feb 22, 9:57 pm, mamboo <mambooo> wrote:
> Hello... I have a problem with preg_replace...
>
> In a long text I have some links...
>
> "My name is <link>Lucas|http://mysite.com/Lucas.html</link> and this is
> my <link>car|http://mysite.com/my_car.html</link> so..."
>
> using preg_replace I would like to transform the text before it would be
> displayed to add a session_id.
>
> It would become ""My name is <a
> href="http://mysite.com/Lucas.html?sessid=0343erererere34343">Lucas</a>
> and this ..."
>
> can you help me?

Regular expressions can be a bit daunting. Try this:
preg_replace('/<link>(.*)\|(.*)<\/link>/','<a href="$2?
sessid=0343erererere34343">$1</a>',$text);
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: unset multidimensional array element
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 10:16:28 GMT 2024

Total time taken to generate the page: 0.04036 seconds