Created
November 24, 2016 07:05
-
-
Save andremoreno/5b2ae768c802cae636cf3d77128229db to your computer and use it in GitHub Desktop.
Cara Cepat Mendapatkan Extensi Dari Sebuah Berkas Dengan Menggunakan PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$filename = "/var/www/andremoreno/nama.berkas.jpg"; | |
$path_info = pathinfo($filename); | |
print_r($path_info); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array | |
( | |
[dirname] => /var/www/andremoreno | |
[basename] => nama.berkas.jpg | |
[extension] => jpg | |
[filename] => nama.berkas | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$filename = "/var/www/andremoreno/nama.berkas.jpg"; | |
$extensi = pathinfo($filename, PATHINFO_EXTENSION); | |
// akan menampilkan ".jpg" | |
echo $extensi; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_file_extension($file_name) { | |
return substr(strrchr($file_name,'.'),1); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment