¿how remove an extension in PHP?
In programming times we need to remove or delete an extension of a directory that we have hosted on our server and for that we are going to use php programming that this language helps us with possible solutions for that I will only put a method which is sent the name of the file by parameters with the extension and returns the name of the file without this extension here the code:
function quitar_extension_php($nombre){
$archivo = $nombre;
$extension = pathinfo($archivo, PATHINFO_EXTENSION);
$nombre_base = basename($archivo, '.'.$extension);
return $nombre_base;
}
we emphasize that when we want to call the method we must place it first before making its call as an example:
echo quitar_extension_php("nombre_archivo.txt");
and that's it
0 Comments