Page 1 of 1

Programming question

Posted: 2005-09-26 05:24pm
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.

Posted: 2005-09-26 05:30pm
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?

Posted: 2005-09-26 05:51pm
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.

Posted: 2005-09-26 08:28pm
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.