Toys-Featured Products-Hot Sellers
Whats wrong with semicolon? 😃 Toys;Featured Products;Hot Sellers
Okay here is a try for a solution.
This code should be applied on every each of column[3]
Not to be run on the file or a line,
but only that part of each line called column[3]
or any other column[x] you want to cleanup.
<?php
//But maybe we want to leave one (1) semicolon between words
$text = ";word1;;;;two words;;;word3;;;";
echo '<br />'.$text; //Outputs: ';word1;;;;two words;;;word3;;;'
//remove where there are several ;;; and so
//loop until there is only 1 semicolon left between words
do $text = str_replace(';;', ';', trim($text,';'), $count);
while($count);
echo '<br />'.$text; //Outputs: 'word1;two words;word3'
//Finally we replace remaining semicolon with '-'
$column = str_replace(';', '-', $text);
echo '<br />'.$column; //Outputs: 'word1-two words-word3'
?>