SplFixedArray::fromArray

Advertisement

Syntax Syntax

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

Parameters Parameters

$array

(array) (Required)

$save_indexes

(bool) (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

This site uses Akismet to reduce spam. Learn how your comment data is processed.