Wednesday, 3 June 2015

file size of a string

<?php 
$size 
mb_strlen('This is a string, what is the file size of it?''latin1'); 
if(
$size >= 1024) 
    
$size round($size 10242).' KB'; 
else 
    
$size $size.' bytes'; 
echo 
$size; ?>

Using a string of text, find out how many kilobytes or bytes the string would and/or will take up in a file if it gets saved.

0 comments:

Post a Comment