pkarastelev
4/25/2019 - 11:10 AM

String file size

<?php
  
/*
* Based on Anthony Ferrara's answer on stackoverflow
* https://stackoverflow.com/questions/3511106/filesize-from-a-string
*/
public function getFileSizeOfString(string $string) {
  if (function_exists('mb_strlen')) {
    return mb_strlen($string, '8bit');
  }
  
  return strlen($string);
}