What would be the easiest way to shorten a URL with preg_replace? Let's say a URL looks like this:
http:/ /someurl.com/file_1/something_else/new/file_2.html
I want to reduce it to let's say 30 characters:
http:/ /someurl.com/file_1/some...
Thanks!
Printable View
What would be the easiest way to shorten a URL with preg_replace? Let's say a URL looks like this:
http:/ /someurl.com/file_1/something_else/new/file_2.html
I want to reduce it to let's say 30 characters:
http:/ /someurl.com/file_1/some...
Thanks!
I think there's a little more to it if you still want the link to work ;)
Have a look at this: https://github.com/briancray/PHP-URL-Shortener
In that case, why not use substr() http://ca3.php.net/manual/en/function.substr.php