| Server IP : 46.105.57.169 / Your IP : 216.73.216.144 Web Server : Apache System : Linux webd003.cluster120.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : maitricfuz ( 93378) PHP Version : 8.4.10 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/maitricfuz/www/maitric/libraries/vendor/jfcherng/php-diff/src/Utility/ |
Upload File : |
<?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);
}
}
}