title: PHP bytes to kilobytes
body: <p>I have something like this</p>
  
  <pre><code>&lt;td&gt;&lt;?php echo $row_rsPhoto['size']; ?&gt;&lt;/td&gt;
  </code></pre>
  
  <p>and displays the file size in bytes, can do that in kilobytes, I'm trying to do this - function</p>
  
  <pre><code>public function size_as_kb()
  {
      if ($this-&gt;size &lt; 1024) {
          return "{$this-&gt;size} bytes";
      } elseif ($this-&gt;size &lt; 1048576) {
          $size_kb = round($this-&gt;size/1024);
          return "{$size_kb} KB";
      } else {
          $size_mb = round($this-&gt;size/1048576, 1);
          return "{$size_mb} MB";
      }
  }
  </code></pre>
  
  <p>I do not know if this works and how to connect it     <code>$row_rsPhoto['size'];</code> with function</p>
  
  <p>thank you in advance for your help</p>