Jump to content

preg_replace help


AV1611

Recommended Posts

This statement came from lot of help online here...
[code]
$new_str = preg_replace('|\b([a-z\']+)\b|i', "<a href='../concordance.php?WORD=$1' target='reference'>$1</a>", $string);
[/code]

what it does is picks every work from a sting and turns the string into a clickable link.

Now, I need to do something simular:

I need to change every occurance of this string:
[code]
baptistrevival.com:8081/bible
[/code]
to this string:
[code]
www.baptistrevival.com
[/code]

Here is a real sample string:

[code]
$string=
'And the evening <sup><a href='http://baptistrevival.com:8081/bible/strong.php?data=H6153'>[H6153] </a>  </sup> and the morning
<sup><a href='http://baptistrevival.com:8081/bible/strong.php?data=H1242'>[H1242] </a> </sup> were <sup><a href='http://baptistrevival.com:8081/bible/strong.php?data=H1961'>[H1961]</a></sup>  the fourth <sup><a href='http://baptistrevival.com:8081/bible/strong.php?data=H7243'>[H7243]</a> </sup>  day. <sup><a href='http://baptistrevival.com:8081/bible/strong.php?data=H3117'>[H3117]</a> </sup> ';
[/code]


Link to comment
https://forums.phpfreaks.com/topic/4574-preg_replace-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.