Link to home
Start Free TrialLog in
Avatar of pdheady
pdheady

asked on

PHP preg_replace help

Back again....need to fix the output of this example using preg_replace:

href="$http_site_root/companies/one.php?company_id=1643">

to this:

href="xrms/companies/one.php?company_id=1643" target="_blank">

want to add the target to open a new window.

Avatar of pdheady
pdheady

ASKER

i tried something like this but didnt work.

echo preg_replace('#company_id="(.*)"#','company_id="$1" target="blank"', $data);
Avatar of pdheady

ASKER

Well it's more like this.

$data2 .= preg_replace('#\$http_site_root#', '/xrms', $data);

$data3 = preg_replace('#company_id="(.*)"#','company_id="$1" target="blank"', $data2);

echo $data3;
ASKER CERTIFIED SOLUTION
Avatar of MasonWolf
MasonWolf
Flag of United States of America image

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
Avatar of pdheady

ASKER

that did not work.
Avatar of pdheady

ASKER

my bad, i didnt output it correctly. works like a charm now! thanks.

echo str_replace(array('$http_site_root','>'),array( '/xrms',' target="_blank">'), $data);