以编程方式确定搜索操作的数据大小(以字节为单位)

Is it possible to measure data set in terms of bytes?

I was searching for the same as I was required to calculate the bytes of the search I am making on to a QuickBase Table for some debugging process.

Data set could be as simple as a result of the operation

Select * from employees

which fetches a 1000 something rows of 5 columns each

Is it possible to calculate that in a PHP application?

I have not been very successful while googling this.

Any suggestions?

Thanks.

strlen() returns the number of bytes consumed, so you should be able to use something like:

<?php

// example of what you might get back from a SQL SELECT
$data = array (
    array (1, 'foo', 'bar'),
    array (2, 'baz', 'biz'),
);

// tally up the byte count for every scalar in the set
$bytes = 0;
array_walk_recursive($data, function ($item) use (&$bytes) {
    $bytes += strlen((string)$item);
});

echo $bytes . "
";

?>