当前位置:Gxlcms > PHP教程 > php数组入门教程之数组填充

php数组入门教程之数组填充

时间:2021-07-01 10:21:17 帮助过:5人阅读

本文介绍下,有关php数组之数组填充的一个例子,有需要的朋友参考下。

在php编程中,对数组元素进行填充,可以使用array_fill()函数。

来看下面的例子,array_fill()函数——填充数组函数:

";
print_r ($arrayFilled);
echo "
"; $keys = array("string","2",9,"SDK","PK"); $array2 = array_fill_keys($keys,"testing"); echo "
";
print_r ($array2);
echo "
"; ?>

运行结果:

Array ( [0] => Array ( [0] => a [1] => b [2] => c [3] => d )

[1] => Array ( [0] => a [1] => b [2] => c [3] => d )

[2] => Array ( [0] => a [1] => b [2] => c [3] => d )

[3] => Array ( [0] => a [1] => b [2] => c [3] => d )

[4] => Array ( [0] => a [1] => b [2] => c [3] => d )

) Array ( [string] => testing [2] => testing [9] => testing [SDK] => testing [PK] => testing )

人气教程排行