[SOLVED ] str_replace

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

[SOLVED ] str_replace

Post by ol4pr0 »

i wanted to replace the following

lets say string looks like this

/word/number/number.doc

this should become

number.doc

the first i dont have troubles with.
the first number i do.. since this is not always the same
i tried replacing /%/ and /*/ neither of them seemed to work.
Last edited by ol4pr0 on Tue Sep 07, 2004 6:57 pm, edited 1 time in total.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

dont need replace.

Code: Select all

<?php
$string = "/word/number/number.doc";
$array = explode("/", $string);
$string = $array[sizeof($array)-1];
?>
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Thanks alot.
Post Reply