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.

function folderSize($dir){
$count_size = 0;
$count = 0;
$dir_array = scandir($dir);
  foreach($dir_array as $key=>$filename){
    if($filename!=".." && $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);
return $count_size;

Call the function:

  $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.


Continue reading Slot Machine

PHP: array() Function

An array in PHP is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more. As array values can be other arrays, trees and multidimensional arrays are also possible.

Create an indexed array named $cars, assign three elements to it, and then print a text containing the array values:

echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";

Continue reading PHP: array() Function

Friends in War – Image Gallerie v1.0

Friends in War Image Gallerie is a free is a user-friendly Image Gallerie script.
Users can register. A admin can see the users and edit or delete them.
The script comes with a very user friendly admin system where you can change things such as: Edit members, site looks, add and edit categories, add and edit images.
Friends in War Image Gallerie has an optional admin selectable theme system with a number of themes pre-installed, You can select your theme in the admin menu.
The scripts is 100% bootstrap and ready for every device such as phone, tablet, laptop and desktop.
Continue reading Friends in War – Image Gallerie v1.0