<?php
$string = 'A sample string with @@@@@@@@@@@@';
echo $string;
$str2 = trim(preg_replace('/@+/', '@', $string));
echo $str2;
// Remove multiple spaces
$string = 'A '; // lot of spaces after 'A'
echo trim(preg_replace('/\s+/', ' ', $string))
?>
$string = 'A sample string with @@@@@@@@@@@@';
echo $string;
$str2 = trim(preg_replace('/@+/', '@', $string));
echo $str2;
// Remove multiple spaces
$string = 'A '; // lot of spaces after 'A'
echo trim(preg_replace('/\s+/', ' ', $string))
?>
Comments
Post a Comment