Programming question

GEC: Discuss gaming, computers and electronics and venture into the bizarre world of STGODs.

Moderator: Thanas

Post Reply
User avatar
Spyder
Sith Marauder
Posts: 4465
Joined: 2002-09-03 03:23am
Location: Wellington, New Zealand
Contact:

Programming question

Post by Spyder »

(In PHP)

I've got a simple matrix $row[$x][$y], where $x represents the current row and $y represents the current column.

I can get the maximum value of the columns in the current row with max($row[$x]). Does anyone know how I could fetch the maximum of the value of the rows in the current column? I tried max($row[][$y]) but that returned a parse error (not unexpectedly.) I'm basically trying to compare the first element in each row, which I'll then loop for the second element and third element, ect.
:D
User avatar
Jaepheth
Jedi Master
Posts: 1055
Joined: 2004-03-18 02:13am
Location: between epsilon and zero

Post by Jaepheth »

I don't know PHP syntax, but couldn't you just make a variable, set it to the value of the first value in a column, test to see if the next value is larger, if so assign it to your variable, then increment to the next value?
Children of the Ancients
I'm sorry, but the number you have dialed is imaginary. Please rotate the phone by 90 degrees and try again.
User avatar
Spyder
Sith Marauder
Posts: 4465
Joined: 2002-09-03 03:23am
Location: Wellington, New Zealand
Contact:

Post by Spyder »

Yes, but I was trying to do it in as few lines as possible.
I ended up just using a loop to increment the value of $x. Ugly, but it works.
:D
nickolay1
Jedi Knight
Posts: 553
Joined: 2005-05-25 12:42am
Location: Marietta, GA

Post by nickolay1 »

If there existed a function, it would probably do the same internally, so you aren't losing much, if anything, in terms of speed.
Post Reply