Birden fazla beyaz boşluk Çıkarma

2 Cevap php

Yani, ben gibi bir dize varsa

"hello    what is  my    name"

Nasıl alanlarda tüm almak ve tek bir boşluk ile her değiştirebilirsiniz?

2 Cevap

Bu yapmak gerekir:

$replaced = preg_replace('/\s\s+/', ' ', $text);

Output:

hello what is my name

Çözüm bulundu:

<?php

$str = ' This is    a    test   ';
$count = 1;
while($count)
    $str = str_replace('  ', ' ', $str, $count);

?>