<?php
//This is the file name from which we are going to get its extension and display it to the user on the screen
$my_file_name = "image.jpg";
/* First Approach "explode/end" */
$first_extension = end(explode('.', $my_file_name));
echo "1 ".$first_extension;
/* Second Approach "strrchr" */
$second_extension = substr(strrchr($my_file_name, '.'), 1);
echo "<br><br>2 ".$second_extension;
/* Third Approach "strrpos" */
$third_extension = substr($my_file_name, strrpos($my_file_name, '.') + 1);
echo "<br><br>3 ".$third_extension;
/* Forth Approach "preg_replace" */
$forth_extension = preg_replace('/^.*\.([^.]+)$/D', '$1', $my_file_name);
echo "<br><br>4 ".$forth_extension;
/* Fifth Approach "split" */
$fifth_extension = split("[/\\.]", $my_file_name);
$fifth_extension_counter = count($fifth_extension)-1;
$fifth_extension_displayer = $fifth_extension[$fifth_extension_counter];
echo "<br><br>5 ".$fifth_extension_displayer;
/* Sixth Approach "pathinfo" */
$sixth_extension = pathinfo($my_file_name, PATHINFO_EXTENSION);
echo "<br><br>6 ".$sixth_extension;
/* Finally, get the File Name using "pathinfo" */
$get_the_filename = pathinfo($my_file_name, PATHINFO_FILENAME);
echo "<br><br><b>Filename:</b> ".$get_the_filename;
?>
Our objective is to reach a place where our services will be highly regarded by businesses from various industrial domains for building their innovative busines solutions with our cutting-edge technological expertise, interactive designs and uncompromised quality.
We aspire to help businesses ranging from startups to enterprises, who reach out to us with their requirements, in achieving great lengths, expanding their reach, upscaling their products, and generate a large user-base with our outstanding and cost-effective services.
Copyright © 2011 - 2024 | All Rights Reserved