Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts

    replace the empty space with ',' from unicode

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

  • #2
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    Here:

    PHP Code:
    <?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...

  • #3
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts
    sorry,it give me the result still not right, but it is close.

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

  • #4
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    lol I forgot that you had 2 spaces

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

  • #5
    Regular Coder
    Join Date
    Dec 2006
    Posts
    306
    Thanks
    24
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    Ur welcome!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •