Status
Not open for further replies.

r0ck

Active Member
1,628
2009
63
0
PHP:
$replace = array("&");
   $str = str_replace($replace, "and", $str);

Ok, so I figured the above out and its working great for me....however I would also like to replace the emdash with -

but whatever I try it does not seem to work out

PHP:
$replace = array("what here?");
   $str = str_replace($replace, "-", $str);
 
9 comments
try one of these:
PHP:
$replace = array(chr(151)); 
   $str = str_replace($replace, "-", $str); 
$replace = array('—'); 
   $str = str_replace($replace, "-", $str);
 
Dump part of your file you are converting and post it so we can see the actual characters or attach a sample with the characters that do not convert.
 
try one of these:
PHP:
$replace = array(chr(151)); 
   $str = str_replace($replace, "-", $str); 
$replace = array('—'); 
   $str = str_replace($replace, "-", $str);

chr(151) isn't such a good idea... as UTF-8, ISO, etc. all doesn't have the same numbers for the same chars.
 
try this:
2013 is en-dash and 2014 is em-dash
PHP:
 $str = str_replace("\x2014", "\x2D", $str);
 $str = str_replace("\x2013", "\x2D", $str);
 
Status
Not open for further replies.
Back
Top