I am fairly new to PHP.
I would like to crate FROM $url = "http://www.a1-whatever-4u.com/";
this string: A1-whatever-4u.com
The code bellow produces A1-whatever-4u.com/.
I can't get rid of the '/' at the end.
Also I would like to make sure that if
I have a URL starting with a digit that I wouldn't get an error.
With the current code I might get, because it would try to capitalize the first character after the www.
Code: Select all
<?php
$url = "http://www.a1-whatever-4u.com/";
$replacement = "strtoupper('\$4').'\$5'";
echo preg_replace("/(http:)(\/\/)(www.)([a-zA-Z0-9])([a-zA-Z0-9])+([\/])?/e",
$replacement,
$url);
?>Any suggestions would be appreciated.
Zolee