You are here

public static function SplFixedArray::fromArray in Automatic Updates 7

Same name and namespace in other branches
  1. 8 vendor/paragonie/sodium_compat/src/PHP52/SplFixedArray.php \SplFixedArray::fromArray()

@psalm-suppress MixedAssignment

Parameters

array $array:

bool $save_indexes:

Return value

SplFixedArray

3 calls to SplFixedArray::fromArray()
ParagonIE_Sodium_Core32_BLAKE2b::stringToSplFixedArray in vendor/paragonie/sodium_compat/src/Core32/BLAKE2b.php
Convert a string into an SplFixedArray of integers
ParagonIE_Sodium_Core_BLAKE2b::stringToContext in vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php
Creates an SplFixedArray containing other SplFixedArray elements, from a string (compatible with \Sodium\crypto_generichash_{init, update, final})
ParagonIE_Sodium_Core_BLAKE2b::stringToSplFixedArray in vendor/paragonie/sodium_compat/src/Core/BLAKE2b.php
Convert a string into an SplFixedArray of integers

File

vendor/paragonie/sodium_compat/src/PHP52/SplFixedArray.php, line 55

Class

SplFixedArray
The SplFixedArray class provides the main functionalities of array. The main differences between a SplFixedArray and a normal PHP array is that the SplFixedArray is of fixed length and allows only integers within the range as indexes. The advantage is…

Code

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;
}