My friend in Turkey wrote this for you. Here's what he says: This is probably not the best answer, I am sure there is another way with regular expressions [that would be] quicker but this is what I can put at 08:00AM without sleep :)
echo changethecase("mysite.com/a/ap/apple.html");
function changethecase($txt){
$prefix = "";
if (strtolower(substr($txt,0,7))=="http://") {
$prefix = "http://";
$txt = str_replace($prefix,"",$txt);
}
$tmp = array();
$arr = split("/",$txt);
array_push($tmp,$arr[0]);
for ($i=1;$i
array_push($tmp, strtoupper(substr($arr[$i],0,1)) . substr($arr[$i],1,strlen($arr[$i])-1));
}
return $prefix . implode("/",$tmp);
}
?>
2006-12-02 17:04:54
·
answer #1
·
answered by Secret Agent of God (BWR) 7
·
0⤊
0⤋
You shouldn't need to do that. Use lower case in all directory and file names for compatibility. preg_replace is for complicated stuff and it's slower...
But if you insist... I didn't test it, but it should work:
$a = explode('/', $href); // to transform the url string into an array, like:
// [0] => mysite.com
// [1] =>a
// [2] => ap
// [3] => apple.html
//Then do your transformations, like:
for ($f = 1; $f < 4; $f++)
{
$a[$f] = ucfirst ($a[$f]); // ucfirst capitalizes first letter
}
$href = implode ('/', $a) // glues all back together.
2006-12-03 00:48:08
·
answer #2
·
answered by TonyMR 2
·
0⤊
0⤋
That is very impractical because if your site is hosted on a *nix platform (which the vast majority of sites are), folders are case sensitive so www.yoursite.com/Apple/index.html is NOT the same as www.yoursite.com/apple/index.html
2006-12-03 00:08:29
·
answer #3
·
answered by Anonymous
·
0⤊
0⤋