Home » » Get file extension in php

Get file extension in php

Written By Unknown on Jumat, 07 Oktober 2011 | 05.27

We often need to get the file extension of any file while working with php. We can get it in different ways. Here are some functions to get the file extension. Just pass the filename

  $file='myimage.jpg';

(1) echo $ext1= end(explode('.',$file));

(2) echo $ext2= array_pop(explode('.',$file));

(3) echo $ext3= substr(strrchr($file,'.'),1);

(4) $ext4=pathinfo($file);
echo $ext4['extension'];


All above will give us file extension.
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger