In php, there is a built-in function strcmp
to compare if two strings are same or not.
Returning value is integer number that if the first parameter is greater than the second I get > 0
, if not < 0
and if the same 0
.
So the part I don't get is comparing string as number. Does PHP convert string to number and if so how's PHP converting?
$a = 'acorn';
$b = 'zebra';
var_dump( strcmp($a, $b) ); // -25 <- what's this number? seems like alphabetical position...nnn
Doesn't it really matter what number I get, shall I just take what it is?