replace characters starting from undercore – PHP

  php

Q(Question):

There is a file name like servername_20080506.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

A(Answer):

There is a file name like servername_20080506.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_name, "_");[/php]

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

A(Answer):

thanks, it worked. Re: has significance.

A(Answer):

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($conn_id, $file*)

$file is the server name part.

A(Answer):

warning: you are double posting in this forum!.

The other thread has been removed.

moderator

A(Answer):

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?

A(Answer):

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

moderator

LEAVE A COMMENT