I want to show uploaded pdf on the webpage. The name of pdf comes from the database with a timestamp. How to show only that pdf name without a timestamp and extention? Here is my code but it is not generating required output.
$count = strlen($promotion_data->pdf1);
$pos=strrpos($promotion_data->pdf1,"_");
$poz = $count - $pos;
$SavePath=substr($promotion_data->pdf1,0,$poz);//name to echo
file-name in db is Beginning-Zend-Framework_1399126117.pdf.
Probably it should work:
$ext = pathinfo($promotion_data->pdf1, PATHINFO_EXTENSION);
$pos=strrpos($promotion_data->pdf1,"_");
$SavePath=substr($promotion_data->pdf1,0,$pos).'.'.$ext; //name to echo
If your file names have non ASCII letters and symbols you should also set valid encoding as for example
mb_internal_encoding("UTF-8");
and use mb_substr and mb_strrpos insted of substr and strrpos