Use the pathinfo() PHP function to remove the file extension from a string.


Example:

<?php

// Initializing a variable with filename 
$file = 'testfile.txt';

// Extracting only filename 
$str = pathinfo($file, PATHINFO_FILENAME);

// Printing the result 
echo $str;
?>

Output:

testfile



Are you facing problems in understanding this article?
You can watch the video. Watch it now