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 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'] } 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
Archived
This topic is now archived and is closed to further replies.