DynamicArray::fromArray

(Available since version 1.0)

DynamicArray::fromArrayImport a PHP array in a DynamicArray instance

Description

public static SEIDS::Arrays::Dynamic::DynamicArray DynamicArray::fromArray ( array $array [, bool $save_indexes = true ] )

Import the PHP array array in a new SEIDS::Arrays::Dynamic::DynamicArray instance.

Parameters

array

The array to import.

save_indexes

Try to save the numeric indexes used in the original array.

Return Values

Returns an instance of SEIDS::Arrays::Dynamic::DynamicArray containing the array content.

Examples

Example #1 DynamicArray::fromArray() example

<?php
require 'vendor/autoload.php'// A PSR-4 or PSR-0 autoloader
use \SEIDS\Arrays\Dynamic\DynamicArray;

$fa DynamicArray::fromArray(array(=> 1=> 2=> 3));

foreach(
$fa as $i => $v) {
  echo 
$i.':';
  
var_dump($v);
}

echo 
"\n";

$fa DynamicArray::fromArray(array(=> 1=> 2=> 3), false);

foreach(
$fa as $i => $v) {
  echo 
$i.':';
  
var_dump($v);
}
?>

The above example will output:

0:int(2)
1:int(1)
2:NULL
3:int(3)

0:int(1)
1:int(2)
2:int(3)

To Top