You are here: Passing multi-dimensional arrays to functions « All PHP « IT news, forums, messages
Passing multi-dimensional arrays to functions

Posted by Otie on 09/28/40 11:43

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация