Re: Passing multi-dimensional arrays to functions
- From: "Otie" <otie_nospam@xxxxxxxxxxxx>
- Date: Mon, 27 Mar 2006 14:29:31 -0800
I think the problem is solved.
An "unset" command was in the wrong place - in the loop I had. That was
clearing the first dimension.
-----
Otie
"Otie" <otie_nospam@xxxxxxxxxxxx> wrote in message
news:1-adnTgcRM2XWrrZRVn-gA@xxxxxxxxxxxxxxx
Please help, someone.
I have a multi-dimensional array called $longitude. It is 2 x 5 elements
defined as:
$longitude[0][0] = "1";
$longitude[0][1] = "2";
$longitude[0][2] = "3";
$longitude[0][3] = "4";
$longitude[0][4] = "5";
$longitude[1][0] = "6";
$longitude[1][1] = "7";
$longitude[1][2] = "8";
$longitude[1][3] = "9";
$longitude[1][4] = "10";
Why does the following function call only pass the values for the second
element to the function - in other words, 6, 7, 8, 9, or 10?
When I try to read $longitude[0][1] or anything in that first dimension, I
get nothing.
function call:
$num = GetCoordinates($longitude);
Function GetCoordinates($longitude)
{
$nums = 0;
for ($y = 0; $y <= 4; $y++)
{
$sy = $longitude[0][$y]; //$longitude[0][$y] always reads
nothing
for ($x = 0; $x <= 4; $x++)
{
$sx = $longitude[1][$x] //$longitude[1][$x] always pulls the
right value
$nums++;
}
}
return $nums;
}
Thank you.
Otis
.
- References:
- Prev by Date: Re: ANN: Developers, Free MySQL hosting
- Next by Date: Re: beginning PHP problem
- Previous by thread: Passing multi-dimensional arrays to functions
- Next by thread: OT - IT - PHP Developer
- Index(es):
Relevant Pages
|