Home >Backend Development >PHP Tutorial >PHP5.4开始php精简Array数组语法[]

PHP5.4开始php精简Array数组语法[]

WBOY
WBOYOriginal
2016-06-20 13:02:401111browse

PHP 5.4开始php精简Array数组语法

PHP 5.4为您奉上精简的array数组语法:

$fruits = array('apples', 'oranges', 'bananas'); // "old" way
// 学Javascript的数组了
$fruits = ['apples', 'oranges', 'bananas'];
// 关联数组
$array = [
    'foo' => 'bar',
    'bar' => 'foo'
];

当然,旧语法依旧有效,我们多了一种选择。


Statement:
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