Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.