|
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]
|