If you want to know the size without decoding, I believe that the following works:
$size = (int) (strlen(rtrim($data, '=')) * 3 / 4);
Or:
$size = (strlen($data) * 3 / 4) - substr_count(substr($data, -2), '=');
Otherwise, just use strlen() for the decoded data, as stated in Marc.
Matthew
source share