Richie19Rich77
(Seasoned Scripter)
2006-11-12 09:39 PM
2d Arrays in php

Hi All,

I know this is well off topic, but they is no other support like here and it is driving me mad.

I have 2 lots of data that must stick together:

Quote:


FixtureID Points
1 5
2 9
3 6
4 1





Now I want to chuck that into a 2d array, but populate the data of the array via for statement.

I can do it in KiX, but in PHP it don;t look like you can enter data into an 2d array from any other statement apart from when the array is created.

The reason the two lots of data must stay together is because I will sort the points array and the fixturesID must sort with it.

any help would be good.

Thanks

Rich


Sealeopard
(KiX Master)
2006-11-12 10:08 PM
Re: 2d Arrays in php

See whether http://us2.php.net/array helps.

LonkeroAdministrator
(KiX Master Guru)
2006-11-12 10:56 PM
Re: 2d Arrays in php

associative or whatever it's called is the array type you most likely wanna play with.
it's 2d and sortable. and if I recall correctly, php does have it


Richie19Rich77
(Seasoned Scripter)
2006-11-12 11:45 PM
Re: 2d Arrays in php

I got round it in the end, all i had to do was:

Code:

$out = array ();

for ($x = 0; $x < $num_rows ; $x++) {
$out[] = array ($x,$x);
}



LonkeroAdministrator
(KiX Master Guru)
2006-11-12 11:53 PM
Re: 2d Arrays in php

array($x,$x);

that doesn't make sense.


Richie19Rich77
(Seasoned Scripter)
2006-11-14 12:25 AM
Re: 2d Arrays in php

$x,$x was just for testing to see if it populated the 2d array.