Is there a PHP script for automatically converting outbound links to short links?

example - you put down a link somewhere in your HTML or blog post. the script then converts it to yoursite.com/jk9d9s , automatically, so that you don’t have to go through some kind of dashboard every time you want to create a link that redirects.

I know its possible to use .htaccess to redirect links… so maybe if the PHP can access .htaccess and insert a redirect for every link it detects in the HTML? It would need to come up with a string of characters each time, and make sure that no set of random characters has already been used.

Twitter is one example of a website that already does this. Any URL on that site submitted by a user is converted to t.co/ (and what its redirected to shows up as the text for the link).

Here are some that i’ve found:
http://briancray.com/posts/free-php-url-shortener-script

Or you can learn how to make your own:
http://www.youtube.com/watch?v=bAN8GCWUYfA