Set a File size of a string - Php

File size of a strin

Snippet Code


  
Rate this page :
  [ 0 votes]

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

<?php $string="This is used to find the file size of a string"; $size = mb_strlen($string, 'latin1'); if($size >= 1024) $size = round($size / 1024, 2).' KB'; else $size = $size.' bytes'; echo $size; ?>

Tags


Ask Questions

Ask Question