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\]!",&...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |