__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
declare(strict_types=1);
namespace Jfcherng\Diff\Utility;
final class ReverseIterator
{
public const ITERATOR_GET_VALUE = 0;
public const ITERATOR_GET_KEY = 1 << 0;
public const ITERATOR_GET_BOTH = 1 << 1;
/**
* The constructor.
*/
private function __construct()
{
}
/**
* Iterate the array reversely.
*
* @param array $array the array
* @param int $flags the flags
*/
public static function fromArray(array $array, int $flags = self::ITERATOR_GET_VALUE): \Generator
{
// iterate [key => value] pair
if ($flags & self::ITERATOR_GET_BOTH) {
for (\end($array); ($key = \key($array)) !== null; \prev($array)) {
yield $key => \current($array);
}
return;
}
// iterate only key
if ($flags & self::ITERATOR_GET_KEY) {
for (\end($array); ($key = \key($array)) !== null; \prev($array)) {
yield $key;
}
return;
}
// iterate only value
for (\end($array); \key($array) !== null; \prev($array)) {
yield \current($array);
}
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Arr.php | File | 1.56 KB | 0664 |
|
| Language.php | File | 3.34 KB | 0664 |
|
| ReverseIterator.php | File | 1.17 KB | 0664 |
|
| Str.php | File | 748 B | 0664 |
|