Ngôn ngữ PHP - Lấy phần mở rộng của tập tin
Viết chương trình PHP để lấy phần mở rộng của tập tin.
Mã nguồn PHP:
<?php
function file_extension($str1){
$str1=implode("",explode("\\",$str1));
$str1=explode(".",$str1);
$str1=strtolower(end($str1));
return $str1;
}
$file='example.txt';
echo "\n".file_extension($file)."\n";
?>
Lưu đồ thuật toán: