/m", $input, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); $pos = array(); $previous_key = ''; $in_length = strlen($input); // store the following in $pos: // array with key = key of the parsed array's item // value = array(start position in $in, $end position in $in) foreach ($matches as $match) { $key = $match[ 1 ][ 0 ]; $start = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]); $pos[ $key ] = array($start, $in_length); if ($previous_key != '') { $pos[ $previous_key ][ 1 ] = $match[ 0 ][ 1 ] - 1; } $previous_key = $key; } $ret = array(); foreach ($pos as $key => $where) { // recursively see if the parsed out value is an array too $ret[ $key ] = print_r_reverse(substr($input, $where[ 0 ], $where[ 1 ] - $where[ 0 ])); } return $is_object ? (object)$ret : $ret; } } // function print_r_reverse($input) function dhms($seconds, $mode=1) { // build 1d10h30s time output $days = floor($seconds/86400); $hrs = floor($seconds / 3600); $mins = (int) ($seconds / 60) % 60; $sec = (int) ($seconds % 60); if($days>0){ //echo $days;exit; $hrs = str_pad($hrs,2,'0',STR_PAD_LEFT); $hours = $hrs-($days*24); $return_days = $days."d"; $hrs = str_pad($hours,2,'0',STR_PAD_LEFT); }else{ $return_days=""; $hrs = str_pad($hrs,2,'0',STR_PAD_LEFT); } $mins = str_pad($mins,2,'0',STR_PAD_LEFT); $sec = str_pad($sec,2,'0',STR_PAD_LEFT); if ($mode!=1) { if ($return_days=="") { $return["day"]="00"; } else $return["day"]=$days; $return["hour"]=$hrs; $return["min"]=$mins; $return["sec"]=$sec; return $return; } // if ($mode!=1) return $return_days.$hrs."h".$mins."m".$sec."s"; } // function end function filesize_formated($path) { $size = filesize($path); $units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $power = $size > 0 ? floor(log($size, 1024)) : 0; return number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power]; } ?>