There is no need to write lots of code. Even it can be done just by one line of code. See here
Below is the one line code that returns the filename only and removes extension name:
<?php
echo pathinfo('logo.png')['filename'];
?>
It will print
logo