Chopping a string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dag Eilertsen

    Chopping a string

    Hi! I'm wondering if there is an easy way to divide a string into two parts
    (and save them into two varibles).

    The things is that I'm trying to chop a file name in two with the name in
    one variable and the extension in another.

    Tnx


  • Dag Eilertsen

    #2
    Re: Chopping a string

    Never mind! I got it :)

    "Dag Eilertsen" <dag.erik.eiler tsen@broadpark. no> wrote in message
    news:40df52d8@n ews.broadpark.n o...[color=blue]
    > Hi! I'm wondering if there is an easy way to divide a string into two[/color]
    parts[color=blue]
    > (and save them into two varibles).
    >
    > The things is that I'm trying to chop a file name in two with the name in
    > one variable and the extension in another.
    >
    > Tnx
    >
    >[/color]


    Comment

    • Jim Root

      #3
      Re: Chopping a string

      "Dag Eilertsen" <dag.erik.eiler tsen@broadpark. no> wrote in message news:<40df52d8@ news.broadpark. no>...[color=blue]
      > Hi! I'm wondering if there is an easy way to divide a string into two parts
      > (and save them into two varibles).
      >
      > The things is that I'm trying to chop a file name in two with the name in
      > one variable and the extension in another.
      >
      > Tnx[/color]

      A simple way to do it (so long as there is only one dot in the file name)
      list($name, $ext) = explode('.', $fileName);

      Comment

      Working...