Jump to content

Help with PHP preg_replace


karlmarsh05

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.