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