note 96144 added to function.preg-match
| From: | saberdream at live dot fr | Date: | Wed, 10 Feb 2010 23:53:19 +0000 |
| Subject: | note 96144 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-165849@lists.php.net to get a copy of this message | ||
I made a function to circumvent the problem of length of a string... This verifies that the link is
an image.
function verifiesimage($lien, $limite) {
if( preg_match('#^http:\/\/(.*)\.(gif|png|jpg)$#i', $lien)
&& strlen($lien) < $limite )
{
$msg = TRUE; // link ok
}
else
{
$msg = FALSE; // the link isn't image
}
return $msg; // return TRUE or FALSE
}
Example :
if(verifierimage($votrelien, 50) == TRUE)
{
// we display the content...
}
----
Server IP: 69.147.83.197
Probable Submitter: 89.3.52.83
----
Manual Page -- http://www.php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/96144
Del: integrated -- https://master.php.net/note/delete/96144/integrated
Del: useless -- https://master.php.net/note/delete/96144/useless
Del: bad code -- https://master.php.net/note/delete/96144/bad+code
Del: spam -- https://master.php.net/note/delete/96144/spam
Del: non-english -- https://master.php.net/note/delete/96144/non-english
Del: in docs -- https://master.php.net/note/delete/96144/in+docs
Del: other reasons-- https://master.php.net/note/delete/96144
Reject -- https://master.php.net/note/reject/96144
Search -- https://master.php.net/manage/user-notes.php