How to create a fixed length array in php?
伊谢尔伦
伊谢尔伦 2017-05-16 13:15:52
0
4
412

Someone asked me a question during the last interview. I was quite surprised. Do you have any good answers?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(4)
迷茫

SplFixedArray is a fixed-length standard (standard array) and only allows integers in the range as indexes. The advantage is that it allows faster array implementation.

PHP arrays are actually implemented as ordered hash tables (a collection of data)

仅有的幸福

I asked similar questions when interviewing others. What I asked was to write a data structure with 1000 rows * 1000 columns and the values ​​​​are all random numbers from 1 to 99. Many people did not know how to write it. This is obviously For the data structure test, in fact, all developers are playing with arrays, so I have requirements for this. It is very simple if you use two for loops to nest. As for the value, it is even simpler, mt_rand(1,99)... ...

给我你的怀抱

array_pad()

刘奇

The SplFixedArray class http://php.net/manual/zh/clas...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template