Symfony\Polyfill\Mbstring

Mbstring::convertArray │ private static │ CF7 1.0

Метод класса: Mbstring{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$result = Mbstring::convertArray( $array, $toEncoding, $fromEncoding, $referenceIds ): array;
$array(массив) (обязательный)
.
$toEncoding(обязательный)
.
$fromEncoding(обязательный)
.
$referenceIds(true[])
The ids of the references followed to reach $array.
По умолчанию: []

Код Mbstring::convertArray() CF7 6.2.4.1

private static function convertArray(array $array, $toEncoding, $fromEncoding, array $referenceIds = []): array
{
    $r = [];

    foreach ($array as $key => $v) {
        if (null !== $v && !\is_scalar($v) && !\is_array($v)) {
            trigger_error('mb_convert_encoding(): Object is not supported', \E_USER_WARNING);
            continue;
        }

        $k = \is_string($key) ? self::mb_convert_encoding($key, $toEncoding, $fromEncoding) : $key;

        if (\is_string($v)) {
            $v = self::mb_convert_encoding($v, $toEncoding, $fromEncoding);
        } elseif (\is_array($v)) {
            // Only a reference can close a cycle: following the same one twice means one was found
            $id = 70400 <= \PHP_VERSION_ID && ($reference = \ReflectionReference::fromArrayElement($array, $key)) ? $reference->getId() : null;

            if (null !== $id && isset($referenceIds[$id])) {
                trigger_error('mb_convert_encoding(): Cannot convert recursively referenced values', \E_USER_WARNING);
                $v = [];
            } else {
                $v = self::convertArray($v, $toEncoding, $fromEncoding, null === $id ? $referenceIds : $referenceIds + [$id => true]);
            }
        }

        // Keys that collide once converted keep their first value
        $r += [$k => $v];
    }

    return $r;
}