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"]; Quote 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; } Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.