str_replace(' ', '', $string); str_replace(' ', '', $string); str_replace(' ', '', $string); 

How can I replace more than two spaces with one code for nothing ('')?

trim () does not offer, this is not it.

    1 answer 1

    Regexp:

     $string=preg_replace('/ {3,}/','',$string); /* | | || | |_в $string | | || |_на пустую строку | | ||_и более раз | | |_встреченный 3 | |_пробел (только пробел, для табов и пр символов - \s |_заменить */ 
    • one
      @eicto, quickly. Thank you very much! - ModaL
    • one
      Great comment. - Mobyman