note 96144 deleted from function.preg-match by cmb

From: Date: Sun, 04 Dec 2016 12:03:38 +0000
Subject: note 96144 deleted from function.preg-match by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208175@lists.php.net to get a copy of this message
Note Submitter: saberdream at live dot fr ---- 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... } ?>

« previous php.notes (#208175) next »