[PHP] Arrays passed to functions lose their indexing - how to maintain?

2010-07-09 Thread Marc Guay
Hi folks,

I have an array that looks a little something like this:

Array ( [6] = 43.712608, -79.360092 [7] = 43.674088, -79.388557 [8]
= 43.674088, -79.388557 [9] = 43.704666, -79.397873 [10] =
43.674393, -79.372147 )

but after I pass it to a function, it loses it's indexing and becomes:

Array ( [0] = 43.712608, -79.360092 [1] = 43.674088, -79.388557 [2]
= 43.674088, -79.388557 [3] = 43.704666, -79.397873 [4] =
43.674393, -79.372147 )

The indexing is important and I'd like to hang onto it.  Any ideas?  pointers?

Marc

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Arrays passed to functions lose their indexing - how to maintain?

2010-07-09 Thread Ashley Sheridan
On Fri, 2010-07-09 at 15:55 -0400, Marc Guay wrote:

 Hi folks,
 
 I have an array that looks a little something like this:
 
 Array ( [6] = 43.712608, -79.360092 [7] = 43.674088, -79.388557 [8]
 = 43.674088, -79.388557 [9] = 43.704666, -79.397873 [10] =
 43.674393, -79.372147 )
 
 but after I pass it to a function, it loses it's indexing and becomes:
 
 Array ( [0] = 43.712608, -79.360092 [1] = 43.674088, -79.388557 [2]
 = 43.674088, -79.388557 [3] = 43.704666, -79.397873 [4] =
 43.674393, -79.372147 )
 
 The indexing is important and I'd like to hang onto it.  Any ideas?  
 pointers?
 
 Marc
 


Are you passing the array variable by reference? If so, it's probably
the logic of the function that is re-writing the keys. What does the
function look like?

Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] Arrays passed to functions lose their indexing - how to maintain?

2010-07-09 Thread Marc Guay
My bad, I had some leftover code running array_values() on it before
it got passed.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php