maddogandnoriko Posted March 8, 2009 Share Posted March 8, 2009 to get all youtube links I am using: preg_match_all( "/<a[\s]+[^>]*?href[\s]?=[\s\"\']+(http:\/\/youtube.*?)[\"\']+.*?>/",$this->html,$links ); So I thought the same would work to replace them all with nothing, but it does not. Any hints as to why? preg_replace( "/<a[\s]+[^>]*?href[\s]?=[\s\"\']+(http:\/\/rapidshare.*?)[\"\']+.*?>/",'',$this->html); Thanks to all, Todd Quote Link to comment Share on other sites More sharing options...
.josh Posted March 8, 2009 Share Posted March 8, 2009 can you be more specific as to what's not working? I don't know if you were just posting as an example or how you actually have it, but preg_match_all assigns the results to the specified 3rd argument like so: preg_match_all($pattern, $content, $result); print_r($result); with preg_replace, the results must be assigned how things are usually assigned, like so: $result = preg_replace($pattern,$replacement, $content); tbh I have no idea why preg_match(_all) does not do it the same way, but..yeah...anyways, if that's not the issue, then post example content. Quote Link to comment Share on other sites More sharing options...
maddogandnoriko Posted March 8, 2009 Author Share Posted March 8, 2009 Jeez...what a doofus I am! I assumed the preg_replace was just going to replace it in the content as is. I did not assign the preg_replace results to a variable. I really feel stupid sometimes. Thank you for the help! 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.