the-botman Posted December 4, 2009 Share Posted December 4, 2009 ok guys see i need to str_replace this <a class="scorelink" target="match_details" onclick="window.open('','match_details','width=400,height=188,menubar=no,status=no,location=no,toolbar=no,scrollbars=no,resizable=yes')" href="/default.dll/game?comp=cl_group_A&game=357186"> but this part is always different href="/default.dll/game?comp=cl_group_A&game=357186 how do i do this i want to remove the whole string and tought str_replace would be the best Quote Link to comment Share on other sites More sharing options...
Koobi Posted December 4, 2009 Share Posted December 4, 2009 String replacement functions are ideal when you know exactly what you want to replace. If you are unsure about exactly what you want to replace but you have a vague idea of where the data you want to replace will appear, you could use pattern matching. Pattern matching in PHP is done using Regular Expressions. I am assuming you will always want to replace anything that appears within the quotes of the href attribute with your own text. If so, this will work: <?php $subject = "<a class=\"scorelink\" target=\"match_details\" onclick=\"window.open('','match_details','width=400,height=188,menubar=no,status=no,location=no,toolbar=no,scrollbars=no,resizable=yes')\" href=\"/default.dll/game?comp=cl_group_A&game=357186\">"; $replaced = preg_replace('/href=(["\'])[^\1]+\1/i', '', $subject); echo htmlspecialchars($subject); echo '<hr />'; echo htmlspecialchars($replaced); Quote Link to comment 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.