Bluehost.com Web Hosting $6.95

preg_replace() issue

This is a discussion on preg_replace() issue within the PHP General forums, part of the PHP Programming Forums category; 1) function filter() { if($this->post['a'] == "savenews") { $this->post['summary'] = preg_replace("!\[url\](.*)\[/url\]!",&...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-23-2003
Darkstar
 
Posts: n/a
Default preg_replace() issue

1)

function filter() {

if($this->post['a'] == "savenews") {
$this->post['summary'] = preg_replace("!\[url\](.*)\[/url\]!","<a
href=\"\\1\">\\1</a>", $this->post['summary']);
}

-----------------------

2)

global $nwedst;
$nwedst = str_replace("<br>\n", '', $dat->summary);
nwedst = preg_replace("!\<a
href=\"http://(.*)\">(.*)\</a>!","http://\\1", $nwedst);




1 takes a full news post and changes ... into <a
href="...">...</a> and saves the news post
2 takes the full news post and recalls it, changes <a href="...">...</a>...
into ...


1 is used when making a new news post, 2 is used when editing a news post
(making the post user friendly and easy to edit)

2 seems to only replace the first <a href="..."> and the last </a> when
there are multiple links. That's the first of my problems. The second is
that I would like to change my code so that it changes $2
into <a href="$1">$2</a> and back again but i don't know how to change
multiple things with preg_replace().


plz help,
Darkstar
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 04:54 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0