You can use this:
<?php
$text = 'check out this car http://somesite/ford.png'; //get submitted post
$link = strstr($text, 'http://'); //look for an http
$filename = pathinfo ($link, PATHINFO_FILENAME); //get filename from $link
$result = ereg_replace("http://([-]*[.]?[a-zA-Z0-9_/-?&%])*", "[$filename]", $text); // search on $text, find $link, replace it with $filename
echo $result;
?>
Output:
check out this car [ford]
Or if you wanna link to use forum
<?php
$text = 'check out this car http://somesite/ford.png'; //get submitted post
$link = strstr($text, 'http://'); //look for an http
$filename = pathinfo ($link, PATHINFO_FILENAME); //get filename from $link
$result = ereg_replace("http://([-]*[.]?[a-zA-Z0-9_/-?&%])*", "<a href=\"\\0\">\\0</a>", $text); // search on $text, find $link, replace it with $filename
echo $result;
?>
Or you want to up "ford" as link you can use this:
<?php
$text = 'check out this car http://somesite/ford.png'; //get submitted post
$link = strstr($text, 'http://'); //look for an http
$filename = pathinfo ($link, PATHINFO_FILENAME); //get filename from $link
$result = ereg_replace("http://([-]*[.]?[a-zA-Z0-9_/-?&%])*", "<a href=\"\\0\">$filename</a>", $text); // search on $text, find $link, replace it with $filename
echo $result;
?>