How to separate a long string to short string with space each 5 character in php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nhbach
    New Member
    • Dec 2009
    • 7

    How to separate a long string to short string with space each 5 character in php?

    I have a long string in db

    $code = "ACTGTCTACTGGTC TAGCTAGTCATGCTA GTAATCG"
    How to separate a long string to short string with space each 5 character?
    Example:

    ACTGT CTACT GGTCT AGCTA GTCAT GCTAG TAATC
    Please help me, i am a biology student! Thanks!
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    try chunk_split(). I was a Chemistry student.

    Comment

    • nhbach
      New Member
      • Dec 2009
      • 7

      #3
      Thank you in advanced.
      And, if i want to numbered the character in string when I use wordwap to break line this string, what I can do?

      Example:
      $str1 = "GCCGGCGGCCAGGG CGAGCGCTTGCTGGC "
      $str2 = "GCCGG CGGCC AGGGC GAGCC TTGCT GGC" (i can do that now, thanks)

      And:
      1 GCCGG CGGCC
      11 AGGGC GAGCC
      21 TTGCT GGC

      Please help me! Thanks

      Comment

      Working...