Jump to content

[SOLVED] ereg


taith

Recommended Posts

sorry, i know very little of ereg... but i'm trying to make a function to determine if a string is a hex or not... heres what i got sofar...

 

function is_hex($string){
if($string{0}=="#") $string=substr($string,1);
if(strlen($string)!='6') return false;
if(!ereg("[a-fA-F0-9]", $string)) return false;
return true;
}
if(is_hex("#asdf89")) echo 'true';
else echo 'false';

 

any idea why it keeps returning true?

Link to comment
https://forums.phpfreaks.com/topic/45732-solved-ereg/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.