![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check a file is video type or not in php?
Let’s say the following is our variable wherein we have an .mp4 path file −
$movieFileType="demo.mp4";
To check whether the above file is video type, use end() along with explode(). You need to set this in strtolower() and check the condition −
if(strtolower(end(explode(".",$movieFileType))) =="mp4") { } else { }
Example
<!DOCTYPE html> <html> <body> <?php $movieFileType="demo.mp4"; if(strtolower(end(explode(".",$movieFileType))) =="mp4") { echo "The movie ",$movieFileType," is of video type."; } else { echo "The movie ",$movieFileType," is not of video type."; } ?> </body> </html>
This will produce the following output −
Output
The movie demo.mp4 is of video type.
Advertisements