php如果大于

I had problem with php I just dont get it,

here is my code

$pieces = explode("|", $result);
if (count($pieces) == 3){
    $size = $pieces[2];
    echo "here";
    if($bw>=$pieces[2]){
        $manfi = $bw - $pieces[2];
        echo "<br>$manfi<br>";
        echo $size;
    }
    else{
        echo "is not big!!!";echo $size."aaa". $bw;
   }

and here is the out put

hereis not big!!!183773480 aaa 1000000000000000

i just cant figure it out , how this number 1000000000000000 is less than 183773480 ?

The problem is that the number 1000000000000000 is of the datatype string. If you then compare it to an integer it will be casted to an integer. Since 1000000000000000 overflows a 32bit integer that PHP uses it will become a negative value.

try:

$bw = intval($bw);
$pieces = array_map(intval, explode("|", $result));
if (count($pieces) == 3){
    $size = $pieces[2];
    echo "here";
    if($bw>=$pieces[2]){
        $manfi = $bw - $pieces[2];
        echo "<br>$manfi<br>";
        echo $size;
    }else{
        echo "is not big!!!";echo $size."aaa". $bw;
    }
}

I changed $pieces so that it contains an array of integers and I also made sure that $bw contains an integer