Get Folder or Directory size in PHP

In PHP we have an inbuilt function called filesize() to get the size of any file, but what about a directory/ folder. A folder can content many files and sub folders in it. So lets write down a simple PHP function to calculate the folder size.

<?php
function folderSize($dir){
$count_size = 0;
$count = 0;
$dir_array = scandir($dir);
  foreach($dir_array as $key=>$filename){
    if($filename!=".." && $filename!="."){
       if(is_dir($dir."/".$filename)){
          $new_foldersize = foldersize($dir."/".$filename);
          $count_size = $count_size+ $new_foldersize;
        }else if(is_file($dir."/".$filename)){
          $count_size = $count_size + filesize($dir."/".$filename);
          $count++;
        }
   }
 }
return $count_size;
}
?>

Call the function:

<?php
  $folder_name = "myFolder";
  echo folderSize($folder_name);
?>

Continue reading Get Folder or Directory size in PHP

Slot Machine

Here we have a slot machine with a MySQL database and php. My main goal was to write a slot machine script without the use of JavaScript. My conclusion: it is possible but your user will be bored within a minute. Even my daughter (6 years old) said to me that the wheels must be spinning otherwise there is no fun. So there i go, i use a a couple of javascript functions and that’s it. for the rest it’s all php.

In the future i will make more statics of what a player has done but for now this is the result.

Example:

Continue reading Slot Machine

Card flipper using bootstrap 4

Here is a nice card flipper. On the front site the name, image and short description.
And on the back side a longer description with some links to other pages.
Go with your mouse ovr the card and you will see the result.

Example:

New York Skyline

card image

This is the skyline of New York by night.

New York Skyline

The City of New York, often called New York City (NYC) or simply New York, is the most populous city in the United States.

With an estimated 2017 population of 8,622,698 distributed over a land area of about 302.6 square miles (784 km2).

New York City is also the most densely populated major city in the United States.

Continue reading Card flipper using bootstrap 4