Jump to content


Photo

preg_replace help


  • Please log in to reply
1 reply to this topic

#1 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 10 March 2006 - 12:30 AM

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

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:
baptistrevival.com:8081/bible
to this string:
www.baptistrevival.com

Here is a real sample string:

$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> ';




#2 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 10 March 2006 - 01:43 AM

N/M:
$kill = "baptistrevival.com:8081/bible";
$add = "www.baptistrevival.com";
$string=str_replace($kill, $add, $string);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users