返回二维数组 [英] Returning a 2 dimensional array

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

问题描述

我正在尝试编写一个函数来返回一个二维数组,但是

它不起作用。我将返回值减少到1维并且测试了b $ b,以确保问题不在其他地方。当数组为1维时,它没有

问题。


我需要做些什么不同才能返回2
$一个函数的b $ b维数组?

I am trying to program a function to return a 2 dimensional array, but
it''s not working. I reduced the return value to 1 dimension and
tested that to make sure that the problem wasn''t elsewhere. It had no
problem when the array was 1 dimensional.

Is there something different I need to do in order to return a 2
dimensional array from a function?

推荐答案

2005年11月3日星期四12:10:55 -0500,Parrot写道:
On Thu, 03 Nov 2005 12:10:55 -0500, Parrot wrote:
为了从函数中返回一个2
维度数组,我还需要做些什么吗?
Is there something different I need to do in order to return a 2
dimensional array from a function?




是。在函数内创建一个二维数组。返回它。


这很简单:


函数get_2d_array(){

返回数组(数组( ));

}


也许你的功能不是*创建一个2D阵列?

-

JDS | je*****@example.inva 盖子

| http://www.newtnotes.com

DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/



Yes. Create a 2-D array inside the function. Return it.

As simple as this:

function get_2d_array(){
return array(array());
}

Maybe your function is not *creating* a 2D array?
--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/


我确实创建了一个2D数组,我在函数中测试了它。


你的例子没有给出一个创建2D数组的例子,我不会在你的return语句中看到任何变量名。你可以

请扩展吗?


2005年11月3日星期四14:48:19 -0500,JDS< je ***** @ example.invalid>

写道:
I definitely created a 2D array, I tested it within the function.

Your example doesn''t give an example of creating a 2D array and I
don''t see any variable names in your return statement. Could you
please expand on that?

On Thu, 03 Nov 2005 14:48:19 -0500, JDS <je*****@example.invalid>
wrote:
2005年11月3日星期四12:10:55 -0500,Parrot写道:
On Thu, 03 Nov 2005 12:10:55 -0500, Parrot wrote:
为了从函数中返回一个2
维数组,我还需要做些什么吗?
Is there something different I need to do in order to return a 2
dimensional array from a function?



是的。在函数内创建一个二维数组。返回它。

这很简单:

函数get_2d_array(){
返回数组(array());
}

也许你的功能不是*创建一个2D数组?



Yes. Create a 2-D array inside the function. Return it.

As simple as this:

function get_2d_array(){
return array(array());
}

Maybe your function is not *creating* a 2D array?






Parrot(me@myplace.com)TOP POSTED:

:我绝对创建了一个2D数组,我在函数中测试了它。


让我们看看代码。

:你的例子没有给出一个创建2D数组的例子,而且我看起来像是一个数组阵列给我。当你说2D数组时,也许你的意思是




:在你的return语句中看不到任何变量名。你可以吗?
:请扩展一下吗?


变量的名称与此有什么关系?他返回了一个php

" thing"这是一个数组数组。如果你愿意,你可以先将一个东西

分配给一个变量,然后使用该变量返回

的值。我承认我无法在

时刻测试,但很难想象它不会像我期望的那样工作......

Parrot (me@myplace.com) TOP POSTED:
: I definitely created a 2D array, I tested it within the function.

Let''s see the code.

: Your example doesn''t give an example of creating a 2D array and I

It looks like an array of arrays to me. Perhaps you mean something else
when you say "2D array".

: don''t see any variable names in your return statement. Could you
: please expand on that?

What does the name of the variable have to do with this? He returns a php
"thing" which is an array of arrays. You could have assigned that "thing"
to a variable first if you wished, and then returned the value of the
thing by using the variable. I will admit I can not test that at the
moment, but find it hard to imagine it doesn''t work as I expect...


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

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