KingOfHeart Posted October 5, 2009 Share Posted October 5, 2009 I want to divide a number in php. Then if that number has a decimal I want to stop a while loop. Oviously strpos does not work. while($n < strlen($fileData)) { $n++; if($num == 0) { $x = $fileData[$n] / 32; if(strpos($x,".") === false) { echo "X:" . $x . " "; } else { echo "stopped"; return; } } else if($num == 1) { $y = $fileData[$n] / 32; if(strpos($y,".") === false) { echo "Y:" . $y . " "; } else { echo "stopped"; return; } } echo $fileData[$n] . "<br>"; $num++; } Quote Link to comment https://forums.phpfreaks.com/topic/176615-solved-if-decimal-exists-then-stop-looping/ Share on other sites More sharing options...
cags Posted October 5, 2009 Share Posted October 5, 2009 How about... if(!is_int($value)) { break; } Quote Link to comment https://forums.phpfreaks.com/topic/176615-solved-if-decimal-exists-then-stop-looping/#findComment-931097 Share on other sites More sharing options...
.josh Posted October 5, 2009 Share Posted October 5, 2009 or if (($fileData[$n] % 32) != 0) { // is decimal } Quote Link to comment https://forums.phpfreaks.com/topic/176615-solved-if-decimal-exists-then-stop-looping/#findComment-931100 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.