Jump to content


Photo

replace part of string


  • Please log in to reply
4 replies to this topic

#1 aviddv1

aviddv1
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 30 June 2006 - 04:26 PM

Maybe I'm a moron or something.  I can't figure out the most efficent way to do this.

I've got a string: "the test string contants a link. [link]page.php||id=1||click here[link] to see the link."

I want replace [link]...[link] with something like: <a href="<?php echo make_link('page.php','id=1'); ?>">click here</a>

Basically I'm trying to embed a link in a field in a mysql table and then pass the link info to a function called make_link that will add some other parameters and return the full url.

How on earth can I do this?  Any good ideas?

Thanks,
ward



#2 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 30 June 2006 - 04:35 PM

How do you want the link to look like?
This way?
<a href="page.php?id=1">click here</a>

Orio.
Think you're smarty?

(Gone until 20 to November)

#3 Buyocat

Buyocat
  • Members
  • PipPipPip
  • Advanced Member
  • 267 posts

Posted 30 June 2006 - 04:59 PM

Use eregi_replace or preg_replace, you can read about both on php.net if you search for them.  In a nutshell you put a pattern, replacement and string and it does the rest.
Looking for some easy-to-use tools?  Try these, https://sourceforge....jects/utils-php -- I made them myself.  They're distinct tools which are easy to understand and use.  See some examples uses at http://www.anotherearlymorning.com

#4 eunicewt

eunicewt
  • New Members
  • Pip
  • Newbie
  • 4 posts

Posted 30 June 2006 - 05:05 PM

Hi,
    I want to know how to trigger an email to inform the manager this user has updated his profile and it was also uploaded in the database at the same time? Thanks
Eunice

#5 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 30 June 2006 - 05:06 PM

Open a new thread for this.

Orio.
Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users