Voting

: two minus two?
(Example: nine)

The Note You're Voting On

Anonymous
11 years ago
@moostende at gmail dot com
If you want to remove all dashes but one from the string '-aaa----b-c-----d--e---f' resulting in '-aaa-b-c-d-e-f', you CAN use str_replace !

<?php
function foo($str)
{
do {
$str = str_replace("--", "-", $str, $count);
} while (
$count > 0);
return
$str;
}
echo
foo("-aaa----b-c-----d--e---f");
?>

This outputs the following:
-aaa-b-c-d-e-f

<< Back to user notes page

To Top