monkeypaw201 Posted April 16, 2009 Share Posted April 16, 2009 I have a snippet of code from my page here: $filtered2 = str_replace(" nm</td><td class=results width=50 style='align:center'><a href='?site=pl&show=700579c68127f8f25825b1efb8c2f56d' class='link'>details</a></td></tr>","",$sort[1]); But the &show=<value> is always different, yet i need to replace that string regardless... How can this be done? (I prefer code and an explanation if possible) Quote Link to comment https://forums.phpfreaks.com/topic/154283-str_replace-with-wildcard-value/ Share on other sites More sharing options...
premiso Posted April 16, 2009 Share Posted April 16, 2009 <?php $string = " nm</td><td class=results width=50 style='align:center'><a href='?site=pl&show=700579c68127f8f25825b1efb8c2f56d' class='link'>details</a></td></tr> asdfasf"; $filtered2 = preg_replace("~ nm.*?&show=(.*?)' .*?</tr>~is", "", $string); var_dump(htmlentities($filtered2)); die(); ?> I would suggest going with preg_replace instead. Quote Link to comment https://forums.phpfreaks.com/topic/154283-str_replace-with-wildcard-value/#findComment-811121 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.