Sometimes we need to extract image name from the url of the image. For that use the below preg_match script:
<?php
if (preg_match('".*?/?([^/]+?(\.gif|\.png|\.jpg))"', $url, $regs)) {
echo $image = $regs[1];
} else {
$image = "";
}
?>
$url is the url of the image and $regs[1] gives the name of the image.Thats it!
No comments:
Post a Comment