for($i=0;$i < length($string)/$len; $i++) { $codons[$i] = substr($string,$i*$len,$len); } #### $start=0; for ($pos=0; $pos < length($string)-1;$pos++) { if ( substr($string,$pos,1) ne substr($string,$pos+1,1) ) { $runs[$i++] = substr($string, $start,$pos-$start+1); $start=pos; } # end check for end of run } # end loop across letters of string $runs[$i++] = substr($string,$start,$pos-$start+1);