How to automatically create folder if not exists on spesific PATH
Bagaimana cara membuat folder secara rekursif bila tidak ada pada spesifik PATH
Create Folder Recursive PHP

<?php
//define document root first define document root dahulu
define('APP', $_SERVER['DOCUMENT_ROOT'], true);
// [func] path extraction and creation
function _folder_($d){
$d = str_replace(APP, '', rtrim($d, '/'));
$explode = explode('/', rtrim($d,'/'));
$explode = array_filter($explode);
$ready = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN' ? '' : '/');
foreach ($explode as $x) {
$ready = rtrim($ready,'/');
$ready .= '/'.$x;
$status = file_exists(APP.$ready);
if ($status === false){
mdir(APP.$ready);
}
}
return $d;
}
// [func] create folder permission 777
function mdir($x)
{
$oldmask = umask(0);
mkdir($x, 0777);
umask($oldmask);
}

//Usage Penggunaan
$folder_target =
?>