...

View Full Version : replace the empty space with ',' from unicode



kamkam
03-14-2009, 12:29 AM
Hi;
I am trying to replace the empty space with the ',' from a string which group by unicode.
I want to have result as following;
锕=錒','锿=鎄','皑=皚','嗳=噯','蔼=藹','霭=靄','爱=愛','嫒=嬡

but my code does not do anything,just give me like the following,could anyone help me, please, thanks.

锕=錒  锿=鎄  皑=皚  嗳=噯  蔼=藹  霭=靄  爱=愛  嫒=嬡


<?php
mb_internal_encoding("UTF-8");
$search=" ";
$replace="','";
$string="锕=錒  锿=鎄  皑=皚  嗳=噯  蔼=藹  霭=靄  爱=愛  嫒=嬡";
echo str_ireplace($search,$replace,$string);
?>

sea4me
03-14-2009, 01:08 AM
Here:


<?php
$search=" ";
$replace="','";
$string="锕=錒  锿=鎄  皑=皚  嗳=噯  蔼=藹  霭=靄  爱=愛  嫒=嬡";
echo str_ireplace($search,$replace,$string);
?>

The spaces on the string isn't the same as the ones you have in search...:thumbsup:

kamkam
03-14-2009, 01:26 AM
sorry,it give me the result still not right, but it is close.

锕=錒','','锿=鎄','','皑=皚','','嗳=噯','','蔼=藹','','霭=靄','','爱=愛','','嫒=嬡

sea4me
03-14-2009, 04:04 AM
lol I forgot that you had 2 spaces :D


<?php
$search="  ";
$replace="','";
$string="锕=錒  锿=鎄  皑=皚  嗳=噯  蔼=藹  霭=靄  爱=愛  嫒=嬡";
echo str_ireplace($search,$replace,$string);
?>

kamkam
03-14-2009, 04:12 AM
Thanks, in fact i have set two spaces for that from your code already, but it give me nothing when print out the result, but this time i copy and paste your code, and it works.

Thanks your time again.

sea4me
03-14-2009, 06:42 AM
Ur welcome!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum