-2

Possible Duplicate:
How to replace Microsoft-encoded quotes in PHP

My string is

iPad Applications In Bloom’s Taxonomy and ducause Review: “This Game Sucks”

Now I want to replace " ’ " by " ' " and " “ " by ' " '

Cœur
  • 37,241
  • 25
  • 195
  • 267
Tushar Ahirrao
  • 12,669
  • 17
  • 64
  • 96
  • 3
    I think what you're looking for is explained here in detail: http://stackoverflow.com/questions/1262038/how-to-replace-microsoft-encoded-quotes-in-php. – Fatih Sep 19 '11 at 12:46

5 Answers5

1
echo str_replace(array('’', '“', '”'), array("'", '"', '"'), 'iPad Applications In Bloom’s Taxonomy and ducause Review: “This Game Sucks”');

See the results of execution on ideone

zerkms
  • 249,484
  • 69
  • 436
  • 539
1
$text = "iPad Applications In Bloom’s Taxonomy and ducause Review: “This Game Sucks”"
$search = array("’", "“");
$replace = array("'", '"');
$new_text = str_replace($search,$replace,$text);
Ergec
  • 11,608
  • 7
  • 52
  • 62
  • But when i replace my string with variable name it does not work like this : str_replace(array('’', '“',"”"), array("'", '"','"'), $variableName); – Tushar Ahirrao Sep 19 '11 at 12:58
  • It definitely works unless those characters look similar but are actually different. check character codes of each letter in your string with `chr()` command in php and use like this `$search = array(chr(xxx), chr(xxx));` – Ergec Sep 19 '11 at 13:17
0

Try str_replace function.

KV Prajapati
  • 93,659
  • 19
  • 148
  • 186
0

You can use str_replace :

 $string = str_replace(array("’",  "“"), array("'", '"'), $string);
krtek
  • 26,334
  • 5
  • 56
  • 84
  • But when i replace my string with variable name it does not work like this : str_replace(array('’', '“',"”"), array("'", '"','"'), $variableName); – Tushar Ahirrao Sep 19 '11 at 12:58
0

You can create array of character what you want to remove and use str_replace to replace with something else.

ex: $remove = array(',','"',"'",'by','and son on..');
$str = iPad Applications In Bloom’s Taxonomy and ducause Review: “This Game Sucks”;
$return = str_replace($remove,' ',$str);

thanks..

sankar.suda
  • 1,097
  • 3
  • 13
  • 26
  • But when i replace my string with variable name it does not work like this : str_replace(array('’', '“',"”"), array("'", '"','"'), $variableName); – Tushar Ahirrao Sep 19 '11 at 12:58