I want to rewrite the categories.
$catfile = .txt file where the categories and subcategories are, like "Business::Accounting & Finance"
I wish to replace "::","/" - "&","and" - " ","-"
And have something like: Folder/Business/Accounting-and-Finance
Could somebody help me with this?
My PHP code:
<?php
$catary = file($catfile);
$lastmajor = "xxnone";
for ($i=0; $i<count($catary); $i++) {
$cdisp = rtrim($catary[$i]);
$cmach = rawurlencode($cdisp);
$cdisp2 = explode("::", $cdisp);
$cmach2 = explode("%3A%3A", $cmach);
$majorlink = "<a class=catmajor href='".$baseHREF."Folder/show.php?cat=" . $cmach2[0] . "'><strong>" . $cdisp2[0] ."</strong></a>";
$minorlink = "<a class=catminor href='".$baseHREF."Folder/show.php?cat=" . $cmach2[0] . "%3A%3A" . $cmach2[1] . "'>" . $cdisp2[1] ."</a>";
if ($cmach2[0] != $lastmajor) {
$cats .= "<p>" . $majorlink . " \n";
$lastmajor = $cmach2[0];
$cats .= " <br>" . $minorlink;
} else {
$cats .= ", " . $minorlink;
}
}
?>
<?php echo "$cats"; ?>
Thanks a lot.