Convert HTML to text - keeping Links intact
Posted: Sat Jun 18, 2005 1:19 pm
Im using the search and replace patterns from the preg_replace example in the php.net manual to convert HTML to text.
But I want all the links intact.
So I changed the second line of
to
but isnt working well.
I even tried [^a\/a] but this is treated as
a,\/,a
and not as
a,\/a
Any way to get \/a treated as one ?
Thanks
But I want all the links intact.
So I changed the second line of
Code: Select all
$search = array ('@<script[^>]*?>.*?</script>@si', // Strip out javascript
'@<[\/\!]*?[^<>]*?>@si', // Strip out HTML tags
'@([\r\n])[\s]+@', // Strip out white space
'@&(quot|#34);@i', // Replace HTML entities
'@&(amp|#38);@i',
'@&(lt|#60);@i',
'@&(gt|#62);@i',
'@&(nbsp|#160);@i',
'@&(iexcl|#161);@i',
'@&(cent|#162);@i',
'@&(pound|#163);@i',
'@&(copy|#169);@i',
'@&#(\d+);@e'); // evaluate as phpCode: Select all
'@<[^a][^\/a][\/\!]*?[^<>]*?>@si', // Strip out HTML tags EXCEPT <a></a>I even tried [^a\/a] but this is treated as
a,\/,a
and not as
a,\/a
Any way to get \/a treated as one ?
Thanks