PHP Knowledge Base

pathinfo

php
<?php

$URL = "https://www.useyourlocaldevelopment.com/images/logo.jpg";

echo "<p>\$URL = \"https://www.useyourlocaldevelopment.com/images/logo.jpg\"</p>";

$path_parts = pathinfo ($URL);

echo $path_parts['dirname'], "<br>";
echo $path_parts['basename'], "<br>";
echo $path_parts['extension'], "<br>";
echo $path_parts['filename'], "<br>";


echo  $path_parts['dirname'] ."/". $path_parts['filename'].".png";

?>
output

$URL = "https://www.useyourlocaldevelopment.com/images/logo.jpg"

['dirname'] = https://www.useyourlocaldevelopment.com/images
['basename'] = logo.jpg
['extension'] = jpg
['filename'] = logo

https://www.useyourlocaldevelopment.com/images/logo.png