PHP,数组的数组VS对象Array [英] PHP, Array of Arrays vs Array of Objects

查看:150
本文介绍了PHP,数组的数组VS对象Array的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建基于一些数据,我从什么地方获取一个PHP数据结构的过程。

I'm in the process of creating a PHP data structure based on some data I'm fetching from somewhere.

如果我会带code此信息在某些标准的容器,如XML或JSON,我会用这样的结构:

If I would encode this information in some standard container, like XML or JSON, I would use this structure:

[ {'name': 'Lupin', 'age': '13'}, {'name': 'Igor', 'age': '24'}, ... ];

不过我有点不确定的PHP(数组的数组VS对象Array)来使用的。

However I'm a bit unsure what to use in PHP ( Array of Arrays vs Array of Objects ).

一件事是,我真的不那么在意的可读性,但我希望能够解决这阵列(这是相当大的)。例如,我可能要对它进行排序的的最大的年龄,或别的东西。

One thing is that I don't really care much about readability, but I would like to be able to sort this Array (which can be quite big). For example I might want to sort it for the biggest age, or something else.

所以,我应该用什么结构,我在PHP中的数据?我想一些性能比较居多。

So what structure should I use for my data in PHP? I would like some performance comparisons mostly.

推荐答案

@Temporary表:MySQL的的确允许通过创建临时表CREATE TABLE TEMPORARY 。这些表只对当前连接可见的,所以一定不要使用持久连接;)

@Temporary Table: MySQL indeed allows creating temporary tables through CREATE TEMPORARY TABLE. These tables are only visible to the current connection, so be sure not to use persistent connections ;)

这篇关于PHP,数组的数组VS对象Array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆