Separating a string on commas

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • thanawala27
    New Member
    • Mar 2007
    • 68

    Separating a string on commas

    hi
    I dont know how to seperate a string containing commas.

    suppose i have a string
    $text = "this, is, fine";

    i want to seperate the above string into
    this
    is
    fine

    all the above 3 string shud b in different variables...

    Any Help is appreciated!

    Thanks

    Ravi
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    split function

    Comment

    • adarshtp
      New Member
      • Mar 2007
      • 12

      #3
      Hi Dude,

      use something like this:

      @newval = split(/, /,$string);

      the above will split the string with commas and you will get the output in an array.

      ($val1,$val2,$v al3) = split(/, /,$string);


      :)

      Comment

      • thanawala27
        New Member
        • Mar 2007
        • 68

        #4
        Thank you,

        It worked

        Comment

        Working...