cooldude832 Posted May 18, 2007 Share Posted May 18, 2007 I have a var $var2 and its dynamic off form results. I want to know how i can determine if $var2 has any non numerical (0-9) entries in it and if it does set a variable off it like if($var2=NaN) {$set="no";} else {$set="yes";} Link to comment https://forums.phpfreaks.com/topic/51957-solved-determining-if-a-variable-contains-characters-otherthan-numbers/ Share on other sites More sharing options...
neel_basu Posted May 18, 2007 Share Posted May 18, 2007 <?php $str = '55'; if(is_numeric($str)) { echo 'Yes'; } else { echo 'No'; } ?> It should work. Link to comment https://forums.phpfreaks.com/topic/51957-solved-determining-if-a-variable-contains-characters-otherthan-numbers/#findComment-256107 Share on other sites More sharing options...
cooldude832 Posted May 18, 2007 Author Share Posted May 18, 2007 thank you I tried is_int but that didn't get me anywhere Link to comment https://forums.phpfreaks.com/topic/51957-solved-determining-if-a-variable-contains-characters-otherthan-numbers/#findComment-256109 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.