Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How can i remove some text of a string?

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How can i remove some text of a string?

Postby freddyfiasko » Tue Nov 12, 2002 8:09 am

Trying to find a function that will remove the path of a URL/file-pointer so I end up with the filename only...

Example:

d:\documents\test.doc

becomes

test.doc



Any suggestions?
freddyfiasko
New php-forum User
New php-forum User
 
Posts: 3
Joined: Tue Nov 05, 2002 2:23 pm

Postby Oleg Butuzov » Tue Nov 12, 2002 2:33 pm

i did not unerstud what you want to do ...

you want to edit doc file - it is imposible...

if you want to edit simple plain/text file you need read more about regular expresions
for exemple...
Code: Select all
$message=str_replace("[TONAME]", $name, $message);


Where [TONAME] - is patern

read more at http://www.php.net
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby DanD » Wed Nov 13, 2002 10:24 am

No, that was not the question because I have the
same problem...

this is the text line:

d:\documents\test.doc

The actual question is to search for the first " \"
from the right and display the text after the first
founded " \".

Then I would ask for how to add this in a loop ?

This is realy hard for me to do. I want to display
the list of downloads of our site but just the name.
not the complete url.
DanD
New php-forum User
New php-forum User
 
Posts: 6
Joined: Sun Nov 03, 2002 5:37 am

Postby Oleg Butuzov » Thu Nov 14, 2002 3:40 am

ok... I understend you.

this is another way how to do it...

Code: Select all
$file = file("downloads.txt");
$countdownloads=count($file);

for ($i=0; $i < $countdownloads; $i++)
{
$srting=explode ("\\", $file[$i]);
$filename=count($string)-1;
echo "$string[$filename]<br>\n";
unset($string);
}
Oleg Butuzov
Last Samuray
Last Samuray
 
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am


Return to PHP coding => General

Who is online

Users browsing this forum: Bing [Bot] and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.