Skip to content
WJunction - Webmaster Forum

str_replace help

Status
Not open for further replies.
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.
 
Status
Not open for further replies.

About the author

R
Active Member · Joined
1,628
Messages
63
Reactions
48
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom