Page 1 of 1 1
Topic Options
#170251 - 2006-11-12 09:39 PM 2d Arrays in php
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
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

Top
#170252 - 2006-11-12 10:08 PM Re: 2d Arrays in php
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
See whether http://us2.php.net/array helps.
_________________________
There are two types of vessels, submarines and targets.

Top
#170253 - 2006-11-12 10:56 PM Re: 2d Arrays in php
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
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

Top
#170254 - 2006-11-12 11:45 PM Re: 2d Arrays in php
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
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);
}


Top
#170255 - 2006-11-12 11:53 PM Re: 2d Arrays in php
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
array($x,$x);

that doesn't make sense.

Top
#170256 - 2006-11-14 12:25 AM Re: 2d Arrays in php
Richie19Rich77 Offline
Seasoned Scripter
*****

Registered: 2002-08-16
Posts: 624
Loc: London, England
$x,$x was just for testing to see if it populated the 2d array.
Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 262 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.061 seconds in which 0.028 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org