karlmarsh05 Posted December 22, 2011 Share Posted December 22, 2011 Hi there, I currently use a script that collects some contents from a div box, in this case it collects categories with the links still attached. The problem is that the script ends abruptly if the character ' is within the text it is collecting (e.g. phone's). Is there a way of adding the character to the following code so that it does not recognise the character as an official php character. //### Function to remove anything we don't need, and apply the Ebay URL to the href's function removeStr($val,$numbers,$listed) { $val = preg_replace(array('/<\/span\>/','/<\/li>/','/<span class="cnt">/','/href="/'),array('','','','href="http://stores.ebay.co.uk'),$val); Thanks for any help. Karl Link to comment https://forums.phpfreaks.com/topic/253694-help-with-php-preg_replace/ Share on other sites More sharing options...
Psycho Posted December 22, 2011 Share Posted December 22, 2011 Although I see problems in what that regex is doing, I don't think your problem is with the regex. I think the problem is with HOW you are getting the content for $val before calling the function. I can run that preg_replace on values with single and double quotes without error. Link to comment https://forums.phpfreaks.com/topic/253694-help-with-php-preg_replace/#findComment-1300566 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.