Posts Tagged "Substr"

Get file name and remove file extension using php

Get a File name from url Using PHP Get the “filename”, or the last part of the string, with the basename function. <?php $url = ‘http://www.example.com/feeds/xyz/index.php?filename=abc’; echo basename($url); // print “index.php”; ?> Remove a File Extention Using PHP To strip the file extension from a file name you can use the combination of strrpos() and substr() function like this : <?php $fileName =”index.php”; $name = substr($fileName, 0, strrpos($fileName, ‘.’)); echo $name; //print “index” ?> Shashi Dhar KumarShashi Dhar Kumar Experience…

Read More

Substr () PHP Function

The Substr () PHP Function is used to return part of a string. It is written as substr (string, start, optional length);.The string is whatever string you want to return a portion of. The start is how many characters in to skip before starting. Setting this to 3 would skip the first three and start returning at the forth character. Setting this to a negative number will start counting backwards from the end of the string. Length is an optional…

Read More