mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 01:31:45 +01:00
Arrays > minor refactoring
This commit is contained in:
@@ -4,6 +4,7 @@ Common and useful classes, methods, exceptions etc.
|
|||||||
# 0.0.21
|
# 0.0.21
|
||||||
|
|
||||||
1. Composer > require ext-pcre
|
1. Composer > require ext-pcre
|
||||||
|
2. Arrays > minor refactoring
|
||||||
|
|
||||||
# 0.0.20
|
# 0.0.20
|
||||||
|
|
||||||
|
|||||||
@@ -673,7 +673,7 @@ class Arrays
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$effect = $array;
|
$effect = &$array;
|
||||||
ksort($effect, $sortFlags);
|
ksort($effect, $sortFlags);
|
||||||
|
|
||||||
foreach ($effect as &$value) {
|
foreach ($effect as &$value) {
|
||||||
@@ -822,13 +822,20 @@ class Arrays
|
|||||||
*/
|
*/
|
||||||
public static function getLastElementsPaths(array $array, $separator = '.', $parentPath = '', $stopIfMatchedBy = '')
|
public static function getLastElementsPaths(array $array, $separator = '.', $parentPath = '', $stopIfMatchedBy = '')
|
||||||
{
|
{
|
||||||
$paths = [];
|
/*
|
||||||
|
* No elements?
|
||||||
|
* Nothing to do
|
||||||
|
*/
|
||||||
|
if (empty($array)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($array)) {
|
|
||||||
if (!empty($stopIfMatchedBy)) {
|
if (!empty($stopIfMatchedBy)) {
|
||||||
$stopIfMatchedBy = self::makeArray($stopIfMatchedBy);
|
$stopIfMatchedBy = self::makeArray($stopIfMatchedBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$paths = [];
|
||||||
|
|
||||||
foreach ($array as $key => $value) {
|
foreach ($array as $key => $value) {
|
||||||
$path = $key;
|
$path = $key;
|
||||||
$stopRecursion = false;
|
$stopRecursion = false;
|
||||||
@@ -877,7 +884,6 @@ class Arrays
|
|||||||
$paths += $recursivePaths;
|
$paths += $recursivePaths;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $paths;
|
return $paths;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user