I want to get first file extension in string using php.
now i use this code.
<?php
$string = "aaa.jpgbbb.pngccc.jpg";
if( strpos( $string, $needle ) !== false ) {
list($string) = explode('.png',$string);
echo $string.".jpg";
}
?>
My code only check file extension in string. but can not get first file extension. How can i do ?
. .
For this string first file extension is jpg
.
$string = "aaa.jpgbbb.pngccc.jpg";
. .
For this string first file extension is gif
.
$string = "aaa.gifbbb.pngccc.jpg";
. .
For this string first file extension is png
.
$string = "aaa.pngbbb.pngccc.jpg";