如何用PHP将十进制整数转换为字节?

I need to get how much bytes is a decimal integer with php. For example how can I know if 256,379 is 3-bytes with php? I need a php function to pass 256,379 as input and get 3 as output. How can I have it?

You need calculate logarithm like this:

echo ceil( log ($nmber, 256) );

The number of bytes needed to represent a number can be calculated like this:

echo getNumBytes(256379); // Output: 3
echo getNumBytes(25637959676); // Output 5

function getNumBytes($num) {
    $i = 1;
    do {
        $i++;
    } while(pow(256,$i) < $num);
    return $i;
}