Its is simple ..
$comchan($me,0) - return the number of channel where you are now .. Use an while or Goto function to write all channel to a var .. $comchan($me,n) .. if n = 1 then it will return the 1 channel ..