PHPFront

Home > PHP > IMG bb code
The PHP website created by its users!



IMG bb code


Author
DescriptionReplaces [img]http:///....[/img] with a html img tag. Great for blogs.
RatingThis script has been rated 1/5 (7 votes)

PHP Code


function replaceImg($message) {
   // Make image from [img]htp://.... [/img]
   if (strpos($message, "[img]")){
       $begImg = strpos($message, "[img]");
       $endImg = strpos($message, "[/img]");
       $img = substr($message, $begImg, $endImg-$begImg+6);
  
       $link        = substr($img, 5, $endImg - $begImg -5);
       $htmlImg    = "<img src=$link border='0'>";
      
       $message = str_replace($img, $htmlImg, $message);
       // searches for other [img]-nodes
       $message = replaceImg($message);
   }
   return $message;
}



Rate it: Print Print

Comments


No comments posted yet.

Name
Website
Your comment