PHP: remove filename from path



PHP Snippet 1:

$dirname = pathinfo('images/alphabet/abc/23345.jpg', PATHINFO_DIRNAME);

PHP Snippet 2:

<?php

$dirname = dirname('images/alphabet/abc/23345.jpg'); 
// $dirname === 'images/alphabet/abc/'

$dirname = pathinfo('images/alphabet/abc/23345.jpg', PATHINFO_DIRNAME); 
// $dirname === 'images/alphabet/abc/'

PHP Snippet 3:

<?php

$dirname = dirname('images/alphabet/abc/'); 
// $dirname === 'images/alphabet/'

$dirname = pathinfo('images/alphabet/abc/', PATHINFO_DIRNAME); 
// $dirname === 'images/alphabet/abc/'

PHP Snippet 4:

<?php
    $path = pathinfo('images/alphabet/abc/23345.jpg');
    echo $path['dirname'];
?>