chris_2001 Posted September 20, 2008 Share Posted September 20, 2008 $replace = array("*vocab ", " end*","*def ","*wiki ","*spanish ","*english "); $with = array("<a href='searchdo.php?vocab=", "'>$Search</a>", "<a href='searchdo.php?def=","<a href='http://en.wikipedia.org/wiki/", "<a href='http://www.wordreference.com/es/en/translation.asp?spen=","<a href='http://www.wordreference.com/es/translation.asp?tranword="); $English = str_replace($replace, $with, $EnglishGet); $Spanish = str_replace($replace, $with, $SpanishGet); There is a piece of data that appears after (*vocab or *def or *wiki or *spanish or *english) and before end*. I need it to be in two places (where it is right now and where $Search is) but I can't figure out how to get it in both rather than just the 1 its already in. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/125044-solved-getting-data-between-two-pieces-of-text/ Share on other sites More sharing options...
sKunKbad Posted September 20, 2008 Share Posted September 20, 2008 You might check out the preg_replace() function in the manual. Quote Link to comment https://forums.phpfreaks.com/topic/125044-solved-getting-data-between-two-pieces-of-text/#findComment-646232 Share on other sites More sharing options...
chris_2001 Posted September 20, 2008 Author Share Posted September 20, 2008 It doesn't seem to be working for me but I am probably doing something wrong with my pattern. Any other ideas or a possible preg_replace pattern that would work for me? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/125044-solved-getting-data-between-two-pieces-of-text/#findComment-646236 Share on other sites More sharing options...
sasa Posted September 20, 2008 Share Posted September 20, 2008 look <?php $test ='*vocab sasa end*'; echo $b =preg_replace('|\*vocab *(.*?) *end\*|',"<a href='searchdo.php?vocab=$1'>$1</a>",$test); ?> Quote Link to comment https://forums.phpfreaks.com/topic/125044-solved-getting-data-between-two-pieces-of-text/#findComment-646262 Share on other sites More sharing options...
chris_2001 Posted September 20, 2008 Author Share Posted September 20, 2008 tyvm sir Quote Link to comment https://forums.phpfreaks.com/topic/125044-solved-getting-data-between-two-pieces-of-text/#findComment-646264 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.