Ask substring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ragonz
    New Member
    • Jul 2008
    • 24

    Ask substring

    Is there any function in php to break down string into its substring

    for example

    String : body
    it will return : "bo" and "dy"

    or return the number of substring of a string

    for example

    String : Miracle
    it will return : 3 substring ("Mi" , "ra", and "cle")

    thx in advance
    Ragonz
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by ragonz
    Is there any function in php to break down string into its substring

    for example

    String : body
    it will return : "bo" and "dy"

    or return the number of substring of a string

    for example

    String : Miracle
    it will return : 3 substring ("Mi" , "ra", and "cle")

    thx in advance
    Ragonz
    PHP is not smart enough to know where the string should be split if you do not tell it. How should PHP know to split "Miracle" into "Mi", "ra" and "cle"?

    Comment

    • code green
      Recognized Expert Top Contributor
      • Mar 2007
      • 1726

      #3
      These are not substrings, they are syllables.
      To define them as substrings you need to define rules.
      In this case you could create rules that a string is seperated before or after a vowel, or any additional letter you think. Put these in an array or a string, then use any of the string or regex functions that split or tokenize a string

      Comment

      • ragonz
        New Member
        • Jul 2008
        • 24

        #4
        thx for the help. i'll work on it..

        Regards Ragonz

        Comment

        Working...