2008/01/21 11:38

How to extract file name from given URL ?


That's not too difficult. First, you want to chop anything off after the last \ You can use the command strrpos() to find the position, and then substr to chop it off. However, / is the escape chatacter, so you need to escape that one (/). Finally you need to add +1 the the position since you don't want to include the \ in the result, so:

CODE
$string = substr($string,strrpos($string,'/')+1);


Then, if you want to get the file extension, do the same thing for the . Because there can be more . in a file name you also search for the latest occurence.

CODE
$string = substr($string,0,strrpos($string,'.'));


And there you have it..
Trackback 8 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject Ambien cr 12.5 photo.

    Tracked from Ambien. 2008/12/17 16:53 delete

    Ambien sleeping pill. Ambien. Ambien next day delivery. What color is ambien.

  2. Subject Furniture shopping in high point nc.

    Tracked from High point nc bar furniture companies. 2008/12/29 03:02 delete

    Patrician furniture high point nc.

  3. Subject Free pics zoo porn.

    Tracked from Free zoo porn vids. 2009/03/30 17:26 delete

    Animal sex zoo free porn. Free zoo porn movies. Free zoo porn.

  4. Subject Cialis.

    Tracked from Generic cialis pay by money order. 2009/05/25 15:04 delete

    Cialis. Liquid cialis.

  5. Subject different money making ideas

    Tracked from moneyideas 2010/01/25 08:42 delete

    moneyideas

  6. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 22:03 delete

    moneyideas

  7. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 06:21 delete

    moneyideas

  8. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:43 delete

    moneyideas