Created
September 25, 2013 16:36
-
-
Save jun-ya/6702350 to your computer and use it in GitHub Desktop.
php5.4から連想配列表現が簡単になったので、array()だらけの配列定義がちょっとだけ見やすくなった。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/** | |
* 古い連想配列表現方法を使った多重配列定義例 | |
* | |
*/ | |
$array_old = array( | |
array('index' => 1, | |
array('hoge' => 'hohoho', 'fuga' => 'fufufu'), | |
array('updated_at' => time()), | |
), | |
array('index' => 20, | |
array('hoge' => 'gegege', 'fuga' => 'gagaga'), | |
array('updated_at' => time()), | |
), | |
array('index' => 300, | |
array('hoge' => 'ohohoh', 'fuga' => 'ufufuf'), | |
array('updated_at' => time()), | |
), | |
array('index' => 4000, | |
array('hoge' => 'egegeg', 'fuga' => 'egegeg'), | |
array('updated_at' => time()), | |
), | |
); | |
/** | |
* php5.4から採用された新しい連想配列表現方法を使った多重配列定義例 | |
* | |
*/ | |
$array_new = [ | |
['index' => 1, | |
['hoge' => 'hohoho', 'fuga' => 'fufufu'], | |
['updated_at' => time()], | |
], | |
['index' => 20, | |
['hoge' => 'gegege', 'fuga' => 'gagaga'], | |
['updated_at' => time()], | |
], | |
['index' => 300, | |
['hoge' => 'ohohoh', 'fuga' => 'ufufuf'], | |
['updated_at' => time()], | |
], | |
['index' => 4000, | |
['hoge' => 'egegeg', 'fuga' => 'egegeg'], | |
['updated_at' => time()], | |
], | |
]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment