php8.5
Home/ Manual/ spl / splfixedarray/ SplFixedArray::toArray

SplFixedArray::toArray

PHP function Edit on GitHub ✎

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

Returns a PHP array from the fixed array

Description

SplFixedArray::toArray(): array

Returns a PHP array from the fixed array.

Parameters Parameters

Return Values

Returns a PHP array, similar to the fixed array.

Examples

SplFixedArray::toArray() example

php
<?php
$fa = new SplFixedArray(3);
$fa[0] = 0;
$fa[2] = 2;
var_dump($fa->toArray());
?>

The above example will output:

output
array(3) {
  [0]=>
  int(0)
  [1]=>
  NULL
  [2]=>
  int(2)
}

Source: reference/spl/splfixedarray/toarray.xml · from the official PHP manual (php/doc-en)