解释嵌套数组来一个程序员 [英] Explaining nested arrays to a programmer

查看:105
本文介绍了解释嵌套数组来一个程序员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你是如何解释嵌套数组来编程。我想有人说,有编程的一个入门级的了解,但试图做更复杂的编码。

How have you explained nested arrays to a programmer. I'm thinking someone that has an entry level understanding of programming, but is trying to do more complicated coding.

与阵列阵列工作,但他们不能完全得到他们的头脑周围的念头。

The array with array works, but they can't quite get their mind around the idea.

编辑:示例嵌套数组的:

array(
    'array1' => array(
        'key1' => 'val1',
        'key2' => 'val2',
    ),
    'array2' => array(
        'key1' => 'val1',
        'key2' => 'val2',
    ), 
);

当然,他们通常比这更复杂,也许这就是问题所在。

Of course, they are usually more complicated than this and maybe that's the problem.

推荐答案

告诉他们认为数组作为列表 - 它有助于给他们一些不那么抽象,像一个购物清单中。然后,一个嵌套阵列仅仅是一个列表的列表

Tell them to think of an array as a list- it helps to give them something less abstract, like a grocery list. Then, a nested array is simply a list of lists.

也许我有一个待办事项列表,购物清单,并在amazon.com一个心愿。现在我有我所有的列表清单,我可以通过他们加强看看所有在每个列表中的元素。

Maybe I have a todo list, a grocery list, and a wishlist at amazon.com . Now I have a list of all of my lists, and I can look at all of those elements in each list by stepping through them.

这篇关于解释嵌套数组来一个程序员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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