Skip to content

Instantly share code, notes, and snippets.

@vpadhariya
Last active July 24, 2018 10:23
Show Gist options
  • Select an option

  • Save vpadhariya/e55c8f9620236de6e55edcc956912f36 to your computer and use it in GitHub Desktop.

Select an option

Save vpadhariya/e55c8f9620236de6e55edcc956912f36 to your computer and use it in GitHub Desktop.

Revisions

  1. vpadhariya revised this gist Jul 24, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions create_directory.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    <?php
    /**
    * Creates a directory according to given id and parent dir path
    * @params integer $id this id will decide which directory to return or create and then return
  2. vpadhariya created this gist Jul 24, 2018.
    20 changes: 20 additions & 0 deletions create_directory.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    /**
    * Creates a directory according to given id and parent dir path
    * @params integer $id this id will decide which directory to return or create and then return
    * @params string $parent this will decide what is the path of the directory.
    */
    function createDir($id, $parent)
    {
    $nd_dirlimit = 100;
    $mod = ceil($id / $nd_dirlimit) - 1;

    $dirs = $mod * $nd_dirlimit + 1;
    $dire = $dirs + $nd_dirlimit - 1;

    $tempDir = $dirs.'_'.$dire;

    if(!is_dir($parent.'/'.$tempDir))
    mkdir($parent.'/'.$tempDir,0775);

    return $tempDir;
    }