首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

SplFixedArray::fromArray

(PHP 5 >= 5.3.0, PHP 7)

SplFixedArray::fromArray — Import a PHP array in a SplFixedArray instance

Description

代码语言:javascript
复制
public static SplFixedArray SplFixedArray::fromArray ( array $array [, bool $save_indexes = true ] )

Import the PHP array array in a new SplFixedArray 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 SplFixedArray containing the array content.

Examples

Example #1 SplFixedArray::fromArray() example

代码语言:javascript
复制
<?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);
?>

The above example will output:

代码语言:javascript
复制
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)
}

← SplFixedArray::current

SplFixedArray::getSize →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com