Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可以用数字键构建一个数组但将项目分配给任意键号吗?
IE
$test = array(23=>'first thing', 245=>'second thing');
它本质上没有任何问题,特别是如果您考虑构建一个像您将 ID 分配给值的方法。如果您正在执行诸如循环for($i=0;$i<1000000;$i++)查找值之类的操作,那么是的,您可能需要重新考虑如何编写它。
for($i=0;$i<1000000;$i++)
是的
是的,这是一个关联数组,这就是它有用的原因。