<?php
class Arr {
public static function dot($array, $prepend = '') {
$output = array();
foreach($array as $k => $v) {
if(is_array($v)) {
$output = array_merge($output, static::dot($v, $prepend . $k . '.'));
} else {
$output[$prepend . $k] = $v;
}
}
return $output;
}
public static function dotRev($array, $count = 1, $keySearchPrepend = '') {
$output = array();
foreach($array as $ks => $v) {
$ks2 = explode('.', $ks);
$k = static::lastV($ks2);
if(count($ks2) > $count) {
$output[$k] = static::dotRev($array, $count + 1, $keySearchPrepend . $k . '.');
} else {
if($ks !== $keySearchPrepend . $k) continue;
$output[$k] = $v;
}
}
}
public static function firstV($array) {
if(count($array) < 1) return null;
$values = array_values($array);
return $values[0];
}
public static function lastV($array) {
if(count($array) < 1) return null;
$values = array_values($array);
return $values[(count($values) - 1)];
}
public static function firstK($array) {
if(count($array) < 1) return null;
$values = array_keys($array);
return $values[0];
}
public static function lastK($array) {
if(count($array) < 1) return null;
$values = array_keys($array);
return $values[(count($values) - 1)];
}
}
var_dump(Arr::dotRev(Arr::dot(array(
'app' =>
array (
'Widgets' =>
array (
),
'config' =>
array (
'enviornments' =>
array (
'development' =>
array (
0 => 'development.meta.php',
),
'maintanence' =>
array (
0 => 'maintanence.meta.php',
),
'production' =>
array (
0 => 'production.meta.php',
),
),
'subdomains' =>
array (
'blog' =>
array (
0 => 'blog.meta.php',
),
'files' =>
array (
0 => 'files.meta.php',
),
'i' =>
array (
0 => 'i.meta.php',
),
'www' =>
array (
0 => 'paths.php',
1 => 'www.meta.php',
),
),
0 => 'app.php',
1 => 'database.php',
2 => 'paths.php',
),
'controllers' =>
array (
'blog' =>
array (
),
'files' =>
array (
),
'i' =>
array (
),
'www' =>
array (
),
),
'models' =>
array (
'blog' =>
array (
),
'files' =>
array (
),
'i' =>
array (
),
'www' =>
array (
),
),
'views' =>
array (
'blog' =>
array (
),
'files' =>
array (
),
'i' =>
array (
),
'www' =>
array (
),
),
0 => 'routing.php',
),
'bootstrap' =>
array (
0 => 'autoload.php',
),
'engine' =>
array (
'Assets' =>
array (
0 => 'Asset.php',
1 => 'Assets.php',
),
'Auth' =>
array (
),
'Console' =>
array (
0 => 'Factory.php',
1 => 'Manager.php',
),
'Core' =>
array (
'App' =>
array (
0 => 'Application.php',
1 => 'Enviornments.php',
),
'Errors' =>
array (
0 => 'Error.php',
1 => 'ErrorMessages.php',
2 => 'Errors.php',
),
'Settings' =>
array (
0 => 'Factory.php',
1 => 'Settings.php',
),
0 => 'Constants.php',
1 => 'Functions.php',
),
'Database' =>
array (
'QueryBuilder' =>
array (
0 => 'Builder.php',
1 => 'Factory.php',
),
0 => 'Database.php',
),
'Filesystem' =>
array (
'Exception' =>
array (
0 => 'FileNotFound.php',
1 => 'Filesytem.php',
),
0 => 'Directory.php',
1 => 'File.php',
2 => 'FilePartInterface.php',
3 => 'Filesystem.php',
),
'Html' =>
array (
'Table' =>
array (
0 => 'AbstractTablePart.php',
1 => 'TableBody.php',
2 => 'TableBuilder.php',
3 => 'TableFooter.php',
4 => 'TableHeader.php',
5 => 'TableRow.php',
),
0 => 'Assets.php',
1 => 'HtmlFactory.php',
2 => 'HtmlTag.php',
3 => 'HtmlTags.php',
),
'Http' =>
array (
'Request' =>
array (
0 => 'Factory.php',
1 => 'HttpRequest.php',
2 => 'HttpResponse.php',
),
'Route' =>
array (
0 => 'Router.php',
),
),
'Logger' =>
array (
'Loggers' =>
array (
0 => 'ConsoleLogger.php',
1 => 'DevWebLogger.php',
2 => 'NullLogger.php',
3 => 'StandardLogger.php',
4 => 'WebLogger.php',
),
0 => 'AbstractLogger.php',
1 => 'LoggerInterface.php',
2 => 'LoggerLevel.php',
),
'Request' =>
array (
0 => 'Factory.php',
1 => 'Request.php',
),
'Support' =>
array (
'DataTypes' =>
array (
0 => 'Arr.php',
),
'Interfaces' =>
array (
0 => 'Arrayable.php',
1 => 'Renderable.php',
),
'Traits' =>
array (
),
0 => 'ArrayUtils.php',
1 => 'Constants.php',
2 => 'DataUtils.php',
3 => 'Factory.php',
4 => 'StaticInstance.php',
5 => 'StringUtils.php',
6 => 'Utilities.php',
),
'Views' =>
array (
0 => 'AbstractTemplate.php',
1 => 'CompiledTemplate.php',
2 => 'NativeTemplate.php',
3 => 'TemplatingErrorExcpetion.php',
4 => 'ViewNotFoundException.php',
),
'Widgets' =>
array (
'FileStructure' =>
array (
0 => 'Factory.php',
1 => 'FileStructure.php',
),
),
),
'library' =>
array (
),
'public' =>
array (
'blog' =>
array (
),
'files' =>
array (
),
'i' =>
array (
),
'www' =>
array (
0 => 'index.php',
),
),
0 => '.htaccess',
1 => 'debug.txt',
2 => 'debug2.txt',
3 => 'debug3.txt',
4 => 'output.txt',
5 => 'test.php',
))));
preferences:
36.54 ms | 402 KiB | 5 Q