jakebur01 Posted February 26, 2009 Share Posted February 26, 2009 How can I make the below a 1 if it is not a number or if it is nothing at all. This column contains values like 3, 50, RL, , 2, 1, etc. I want to keep all the current numbers, but make it a 1 if it is blank or if it contains letters. $stdpack1=$row["$stdpack"]; Link to comment https://forums.phpfreaks.com/topic/147069-solved-if-it-is-not-numeric-make-it-a-1/ Share on other sites More sharing options...
The Little Guy Posted February 26, 2009 Share Posted February 26, 2009 Like this: $stdpack1=$row["$stdpack"]; if(!ctype_digit($stdpack1) || empty($stdpack1)){ $stdpack1 = 1; } Link to comment https://forums.phpfreaks.com/topic/147069-solved-if-it-is-not-numeric-make-it-a-1/#findComment-772086 Share on other sites More sharing options...
jakebur01 Posted February 26, 2009 Author Share Posted February 26, 2009 Thank you. Link to comment https://forums.phpfreaks.com/topic/147069-solved-if-it-is-not-numeric-make-it-a-1/#findComment-772092 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.