Removing duplicate characters

<?php
$str = 'foobarrrr';
$str = preg_replace('/(.)\1+/s', '$1', $str);
echo $str; // fobar
?>

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.