zgkhoo Posted October 20, 2007 Share Posted October 20, 2007 if($row[PurchaseNo]==$_post[firstprize]{}; the $row[PurchaseNo] is one digit , while $_post[firstprize] is four digit how to compare $row[PurchaseNo] with the FIRST digit of $_post[firstprize] ? thanks Quote Link to comment https://forums.phpfreaks.com/topic/74073-solved-how-to-compare-the-first-digit-of-a-number/ Share on other sites More sharing options...
wildteen88 Posted October 20, 2007 Share Posted October 20, 2007 Use strstr, eg: if($row['PurchaseNo'] == substr($_POST['firstprize'], 0, 1)) { //PurchaseNo matches first number in $_POST['firstprize'] } else { //PurchaseNo doesn't match first number in $_POST['firstprize'] } Quote Link to comment https://forums.phpfreaks.com/topic/74073-solved-how-to-compare-the-first-digit-of-a-number/#findComment-373932 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.