strcmp equivelant for integers (intcmp) in PHP
Posted
by Chase
on Stack Overflow
See other posts from Stack Overflow
or by Chase
Published on 2010-05-17T20:40:22Z
Indexed on
2010/05/17
20:50 UTC
Read the original article
Hit count: 214
So we got this function in PHP
strcmp(string $1,string $2) // returns -1,0, or 1;
We Do not however, have an intcmp(); So i created one:
function intcmp($a,$b) {
if((int)$a == (int)$b)return 0;
if((int)$a > (int)$b)return 1;
if((int)$a < (int)$b)return -1;
}
This just feels dirty. What do you all think?
© Stack Overflow or respective owner