0

I have a PHP variable that outputs some text on the page i.e. here's the text it outputs

http://URL.com/uploads/gravity_forms/3-464e6bdac9890814218993b7e45c1736/2013/01/hehehecsv10.csv

I would like to remove everything from this text and only show hehehecsv10.csv , how would I go about doing this in PHP

imreal
  • 10,178
  • 2
  • 32
  • 48

2 Answers2

3

The function you're looking for is called basename()Docs:

$string = 'http://URL.com/uploads/gravity_forms/3-464e6bdac9890814218993b7e45c1736/2013/01/hehehecsv10.csv';
echo basename($string); # hehehecsv10.csv

Output is as commented, try the demo if you need to play around with it.

See as well a somehwat related question:

Community
  • 1
  • 1
hakre
  • 193,403
  • 52
  • 435
  • 836
1
$str = 'http://URL.com/uploads/gravity_forms/3-464e6bdac9890814218993b7e45c1736/2013/01/hehehecsv10.csv';

echo end(explode("/",$str));
echo basename($str);
Samuel Cook
  • 16,620
  • 7
  • 50
  • 62