Jump to content

Replace single quote does not work


nelliza111

Recommended Posts

I am trying to do the seemingly simple thing - replace all single quotes in text

 

str_replace ("'", "´", $text);

 

It does not replace anything.

 

I trying escaping single quote, using other similar functions - nope. Also tried to google :)

 

What I an doing wrong? Any help would ne much appreciated.

 

Link to comment
Share on other sites

It works for me.  You do you know that the entity ´ is ´ when parsed by the browser?  Run the script in CLI, you'll see the actual entity.

 

If that doesn't work we need to see more of your script.

 

 

Here is what I did:

ini_set ("display_errors", "1");
error_reporting(E_ALL);

$text = "asdfasdf'asdf";
$replace = str_replace ("'", "´", $text);
echo $replace;
?>

 

CLI: asdfasdf´asdf

Web: asdfasdf´asdf

Link to comment
Share on other sites

The line of code is in function that works perfectly except for single quote line

 

function convert_quotes ($text) {
$text = ereg_replace ('"', """, $text);
$text = str_replace ("'", "´", $text);	
$text = ereg_replace ('“', "“", $text);
$text = ereg_replace ('”', "”", $text);
$text = ereg_replace ('‘', "‘", $text);
$text = ereg_replace ('’', "’", $text);
$text = ereg_replace ('«', "«", $text);
$text = ereg_replace ('»', "»", $text);

return $text;
}

 

I have standard CentOS built, did not edit php.ini. I have not the slightest clue what could be wrong here.

 

Link to comment
Share on other sites

did you run the script via command line, as suggested by Maq? if you are viewing the output with a browser you might be seeing the browser-interpreted code.

 

I need the browser-interpreted code exactly - to replace single quote in html code output. It does not matter how it works from command line. And yes, all browsers show the same - not replaced single quote.

 

Link to comment
Share on other sites

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.