Link to home
Start Free TrialLog in
Avatar of simonplayer
simonplayer

asked on

Remove links from a php string

Hi There,

I need to completly remove html links from a php string. How can I do this? for example;

$string='Client has to pay MX solicitors fee <a href="http://www.tbmc.co.uk/downloads/MXSolicitorsFees.pdf">Click here for details</a> Great long term fixed rate for limited companies!';

I woulld like to change to;

$new_string='Client has to pay MX solicitors fee Great long term fixed rate for limited companies!';

Thanks for your help

Simon.
Avatar of Robin Hickmott
Robin Hickmott

$new_string   =    preg_replace ("\<a.*>\i","",$string);
Avatar of simonplayer

ASKER

Thanks although this does not seem to work.

I am using the following code:

//--
$string='Client has to pay MX solicitors fee <a href="http://www.tbmc.co.uk/downloads/MXSolicitorsFees.pdf">Click here for details</a> Great long term fixed rate for limited companies!';
$new_string=preg_replace ("\<a.*>\i","",$string);
echo $new_string;
//--

Nothings prints out and am getting the following error message;

//--
PHP Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in /home/l/a/landfund/public_html/test.php on line 11
//--

ASKER CERTIFIED SOLUTION
Avatar of Robin Hickmott
Robin Hickmott

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Works fine, Thanks!