Saturday, March 23, 2013
7:56 AM

PHP Replace new lines, tabs and multiple spaces with single space


preg_replace('/\\s+/', ' ',$data) used to Replace new lines, tabs and multiple spaces with single space in PHP

example:
<?php
$data = 'Hi     tab i am 
new line    more                spaces';
$data= preg_replace('/\\s+/', ' ',$data);
echo $data;
?>

Output:

Hi tab i am new line more spaces

0 comments:

Post a Comment

:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.