Jump to content

clear 2 space

- - - - -

  • Please log in to reply
1 reply to this topic

#1
lol33d

lol33d

    Programmer

  • Members
  • PipPipPipPip
  • 149 posts
hi guys

how to clear 2 or more space on the quote?

for example


$str = 'this is  my   test, "clean     my spaces  " thank     you';

i want change this string to:

this is  my   test, "clean my spaces " thank     you'

this is my php code

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


echo $str;

but this code clear all space, i want clear only in " "

thank you

#2
Vaielab

Vaielab

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 547 posts
I use:
$str = preg_replace('/\s{2,}/',' ', $str);
But as far as I know, your code should work... If you ever find why your code dosen't work could you post it here, I'm intrigue!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users