This is a discussion on PHP eregi_replace Why doesn't it... within the PHP General forums, part of the PHP Programming Forums category; Greetings, I'm stumped and was hoping one of you out there can give me a hand. I found some ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Greetings,
I'm stumped and was hoping one of you out there can give me a hand. I found some code on php.net that changes <a href=http://www.somesite.com>Somesite</a> into Somesite Which is perfect. It handles multiple links and everything. The problem I'm having is trying to change it back into the links. By simple reasoning, I figured I'd just have to change a little bit of the working code to make it work, but it doesn't. I'm no expert, as you can probably guess, but I've been working on this for days now and I still can't seem to get it. Any help is much appreciated, Ryan Here is the code that works: (Found it at php.net) $website = eregi_replace('(<a [^<]*href=["|\']?([^ "\']*)["|\']?[^>]*>([^<]*)</a>)','\\3', $website); Here is what I'm working with: $website = eregi_replace('\[url=("|\')?([^ "\']*)("|\')?.*\]([^<]*)\[/URL\]', '<A HREF=\\2>\\4</A>', $website); |
|
|||
|
Well, I figured out something but it only prints out the last
occurance. Is there a way to make it so it prints out all occurances? CODE function AHREF1text($string) { return eregi_replace('\[.*URL=["|\']?([^ "\']*)["|\']?.*\]([^<]*)\[/URL\]', '<A HREF= ONFOCUS=this.blur();></A>', $string); } $HTMLstring = here is linke one PHP.net<BR> and this is link two Nerdbrains.com<BR> and that's that'; echo AHREF1text($HTMLstring); kinslayer13_99@yahoo.com (Ryan) wrote in message news:<6460af62.0308121309.c83811c@posting.google.c om>... > Greetings, > > I'm stumped and was hoping one of you out there can give me a hand. > > I found some code on php.net that changes > <a href=http://www.somesite.com>Somesite</a> > into > Somesite > Which is perfect. It handles multiple links and everything. The > problem I'm having is trying to change it back into the links. > > By simple reasoning, I figured I'd just have to change a little bit of > the working code to make it work, but it doesn't. > > I'm no expert, as you can probably guess, but I've been working on > this for days now and I still can't seem to get it. > > Any help is much appreciated, > Ryan > > Here is the code that works: (Found it at php.net) > $website = eregi_replace('(<a [^<]*href=["|\']?([^ > "\']*)["|\']?[^>]*>([^<]*)</a>)','\\3', $website); > > Here is what I'm working with: > $website = eregi_replace('\[url=("|\')?([^ > "\']*)("|\')?.*\]([^<]*)\[/URL\]', '<A HREF=\\2>\\4</A>', $website); |