Reply to Re: Multi-Dimensional Arrays

Your name:

Reply:


Posted by Jerry Stuckle on 07/19/05 07:23

Chad Lupkes wrote:
> Hoping someone can help me here. It's a simple question, but I'm just not
> getting it.
>
> I have two files:
>
> <?php
> $precinct = array (
> array ( number=>2324,
> centerlat=>-122.31705665588379,
> centerlong=>47.710367959402525,
> etc...
>
> <?php
> include ("precinctdata.php");
> $filename = $_GET['id'];
> $number = $precinct[filename-1][number];
> etc...
>
> I want to assign the value of "2324" to the variable $number. I've done
> this with arrays that start with number=>1, 2, 3, etc., but not successfully
> with specific values.
>
> What am I missing?
>

Try
$precinct = array (
array ('number'=>2324,
'centerlat'=>-122.31705665588379,
'centerlong'=>47.710367959402525,
...
$number = $precinct[$filename-1]['number'];
^ ^ ^

filename is a variable so it needs a $. number is a string, so it needs single
quotes. The same is true when you're creating the array.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original 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

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