Like I supposed there is no efficient way how to do. Thank you for the functios and the help of all of you. Best regards, joe-at
"Manuel VáZquez Acosta" <[EMAIL PROTECTED]> schrieb im Newsbeitrag news:[EMAIL PROTECTED] > Namaste Adwinwijaya: > > I meant there's no PHP function neither to get a column nor to transpose the > matrix. > > The first answer you gave us, retrieves the amount of items in the column, > not the column itself as an array. And the second one, just prints the > matrix, but does not transpose it. > > Joe-At: I suggest you to tell us your exact problem, maybe there's a way to > solve it avoiding matrices, maybe there's a more suitable representation to > the problem's parameters. > > Manu. > > PS: > > This function retrives the j column, assuming that the matrix has no > non-numerical indeces: > > function getColumn($arr, $j) > { > if (isset($arr[$j]) && count($arr[$j])>0) > { > $result = array(); > foreach($arr[$j] as $which) > $result[] = $which; // You could make reference > instead > } > } > > function getTranspose($arr) > { > if (count($arr)>0) > { > $result = array(); > for($i=0; $i<count($arr); $i++) > for($j=0; $j<count($arr[$i]); $j++) > { > if (!isset($result[$j])) > $result[$j] = array(); > > $result[$j][$i] = $arr[$i][$j]; > } > } > } > > Keep in mind this are inefficient functions. > > Manu. > > > "Adwinwijaya" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > Hello Manuel, > > > > Sunday, February 22, 2004, 5:47:02 AM, you wrote: > > > > MVA> As far as I know, there is no such a function. Maybe you should use a > > MVA> different approach. > > MVA> Manu. > > > > MVA> "Joe-At" <[EMAIL PROTECTED]> wrote in message > > MVA> news:[EMAIL PROTECTED] > > >> Hallo, > > >> 1) I want to work with the rows und columns of a tow dimensional > > >> array[i][j]. With array[i] I get the i'th row. But how can I get the > j'th > > >> column? > > >> 2) Is there any command to transpose a two dimensional array? > > >> Thanks for help > > > > > > 1. $array_j = $array[$i] ; > > count($array_j) ; > > > > 2. > > foreach($array as $sub_array){ > > foreach($subarray as $key=>$value) > > echo $key.'=='.$value ; > > } > > > > > > cmiiw > > > > -- > > Best regards, > > adwinwijaya mailto:[EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php