Home > php教程 > php手册 > array_fill:用给定的值填充数组

array_fill:用给定的值填充数组

WBOY
Release: 2016-06-06 19:39:26
Original
1097 people have browsed it

array_fill($start_index,$num.$values) 用value参数的值将一个数组填充num个条目,键名由start_index参数指定的开始。 $arr = array_fill(1,2,['a','b']);echo 'pre';print_r($arr);result:Array( [1] = Array ( [0] = a [1] = b ) [2] = Array ( [0] = a [

array_fill($start_index,$num.$values)
用 value 参数的值将一个数组填充 num 个条目,键名由 start_index 参数指定的开始。

$arr = array_fill(1,2,['a','b']);

echo '<pre class="brush:php;toolbar:false">';
print_r($arr);

result:
Array
(
    [1] => Array
        (
            [0] => a
            [1] => b
        )

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

)
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template