note 96144 modified in function.preg-match by danbrown
| From: | danbrown@php.net | Date: | Wed, 10 Feb 2010 23:54:37 +0000 |
| Subject: | note 96144 modified in function.preg-match by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-165851@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.
<?php
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 :
<?php
if(verifierimage($votrelien, 50) == TRUE)
{
// we display the content...
}
?>
--was--
I made a function to circumvent the problem of length of a string... This verifies that the link is
an image.
<?php
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...
}
?>
http://php.net/manual/en/function.preg-match.php