numbers - php how to detect whole thousands -
i trying detect if number in database whole thousands number.
i.e
25 = false 1000 = true 1578 = false 5000 = true 100000 = true 100005 = false
there ain't way tell if number whole thousand, @ least not php function know of.
i've tried creating array thousands 1billion, can imagine how big array is, if (in_array()). when cleaning code, array 100k lines long, ain't optimal if ask me.
i've searched google way of doing this, can't find useful information.
the modulo (%) operator this.
if ($num > 0 && $num % 1000 === 0) { echo "divisible 1000"; }
note need check if $num 0 because test true because 0 % 1000 = 0
Comments
Post a Comment