SplFixedArray::fromArray

Advertisement

Syntax Syntax

SplFixedArray::fromArray( array $array, bool $save_indexes = true )

Parameters Parameters

$array

(Required)

$save_indexes

(Optional)

Default value: true

Return Return

(SplFixedArray)

Source Source

File: wp-includes/sodium_compat/src/PHP52/SplFixedArray.php

    public static function fromArray(array $array, $save_indexes = true)
    {
        $self = new SplFixedArray(count($array));
        if($save_indexes) {
            foreach($array as $key => $value) {
                $self[(int) $key] = $value;
            }
        } else {
            $i = 0;
            foreach (array_values($array) as $value) {
                $self[$i] = $value;
                $i++;
            }
        }
        return $self;
    }

Advertisement

Advertisement

Leave a Reply