(PHP 5 >= 5.3.0, PHP 7)
SplFixedArray::fromArray — Importe un tableau PHP dans un tableau à taille fixe
$array
[, bool $save_indexes = TRUE
] ) : SplFixedArray
Importe le tableau PHP array
dans un tableau à taille fixe.
arrayLa tableau à importer.
save_indexesTente de préserver les index numérique du tableau original.
Retourne un objet SplFixedArray avec le même contenu que le tableau passé en argument.
Exemple #1 Exemple avec SplFixedArray::fromArray()
<?php
$fa = SplFixedArray::fromArray(array(1 => 1, 0 => 2, 3 => 3));
var_dump($fa);
$fa = SplFixedArray::fromArray(array(1 => 1, 0 => 2, 3 => 3), false);
var_dump($fa);
?>
L'exemple ci-dessus va afficher :
object(SplFixedArray)#1 (4) {
[0]=>
int(2)
[1]=>
int(1)
[2]=>
NULL
[3]=>
int(3)
}
object(SplFixedArray)#2 (3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}