replace characters starting from undercore

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsaray101
    New Member
    • Aug 2007
    • 31

    replace characters starting from undercore

    There is a file name like servername_2008 0506.sql. I would like to remove every character starting from underscore, just leaving the servername. Can somebody help me with this in php?

    Thanks,

    mike
  • hsriat
    Recognized Expert Top Contributor
    • Jan 2008
    • 1653

    #2
    Originally posted by gsaray101
    There is a file name like servername_2008 0506.sql. I would like to remove every character starting from underscore, just leaving the servername. Can somebody help me with this in php?

    Thanks,

    mike
    [php]$new_file_name = strtok($file_na me, "_");[/php]

    Why's that Re: in the title? Any significance?

    Comment

    • gsaray101
      New Member
      • Aug 2007
      • 31

      #3
      thanks, it worked. Re: has significance.

      Comment

      • gsaray101
        New Member
        • Aug 2007
        • 31

        #4
        I have one more question:

        The reason I removed _numbers is to login to ftp server, search for file names matches the servername and remove them.

        then ftp_put the current file. I want to keep one copy on the ftp server.

        Can I do?

        ftp_delete($con n_id, $file*)

        $file is the server name part.

        Comment

        • ronverdonk
          Recognized Expert Specialist
          • Jul 2006
          • 4259

          #5
          warning: you are double posting in this forum!.

          The other thread has been removed.

          moderator

          Comment

          • gsaray101
            New Member
            • Aug 2007
            • 31

            #6
            I am basically trying to do what mdel does in regular ftp program:

            ftp ftp.server.com
            prompt
            mdel servername*

            file name is in this format: servername_date .sql

            Before uploading files to the ftp server, I would like to be able to remove the previous version to only keep one copy in the ftp server.

            can anybody help?

            Comment

            • ronverdonk
              Recognized Expert Specialist
              • Jul 2006
              • 4259

              #7
              Warning: when you continue double posting you will be banned from this forum.

              moderator

              Comment

              Working...