note 64213 deleted from function.preg-replace by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 02:08:18 +0000 |
| Subject: | note 64213 deleted from function.preg-replace by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133093@lists.php.net to get a copy of this message | ||
Note Submitter: Eric
----
Here recently I needed a way to replace links (<a
href="blah.com/blah.php">Blah</a>) with their anchor text, in this case Blah. It
might seem simple enough for some..or most, but at the benefit of helping others:
<?php
$value = '<a href="http://www.domain.com/123.html">123</a>';
echo preg_replace('/<a href="(.*?)">(.*?)<\\/a>/i', '$2',
$value);
//Output
// 123
?>