[情報] How big are PHP arrays really?

看板PHP作者 (拒看低質媒體)時間14年前 (2011/12/17 17:45), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串1/1
剛剛我在別的版看到別人分享的連結 看完以後覺得很有趣, 轉貼至此 http://nikic.github.com/2011/12/12/How-big-are-PHP-arrays-really-Hint-BIG.html 本篇文章最後有提到說 如果沒有要用動態陣列, 可以使用 <?php $startMemory = memory_get_usage(); $array = new SplFixedArray(100000); for ($i = 0; $i < 100000; ++$i) { $array[$i] = $i; } echo memory_get_usage() - $startMemory, ' bytes'; 大概可以省下62%的記憶體 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.25.153.243 ※ 編輯: Wush978 來自: 114.25.153.243 (12/17 17:46)

12/17 21:21, , 1F
還有,索引只能用數字;)
12/17 21:21, 1F

12/17 23:59, , 2F
那不就只有大量計算的number cruncher才適用了。
12/17 23:59, 2F

12/18 02:18, , 3F
挺酷的XD
12/18 02:18, 3F
文章代碼(AID): #1Ex6ISKy (PHP)
文章代碼(AID): #1Ex6ISKy (PHP)