Req #63279 [Opn->Sus]: Mixing the $suffix parameter from basename()

From: Date: Wed, 04 Mar 2020 23:53:12 +0000
Subject: Req #63279 [Opn->Sus]: Mixing the $suffix parameter from basename()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225891@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63279&edit=1

 ID:                 63279
 Updated by:         cmb@php.net
 Reported by:        klaussantana at gmail dot com
 Summary:            Mixing the $suffix parameter from basename()
-Status:             Open
+Status:             Suspended
 Type:               Feature/Change Request
 Package:            Filesystem function related
 Operating System:   Any
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

Looks like this could be implemented in userland without too much
trouble, and I cannot immediately see a benefit of having this
functionality in PHP core.  That doesn't mean that this couldn't
be a useful feature, but it appears that it should be discussed,
and this bug tracker is rather unsuitable for such discussions.
So I encourage anybody interested in this to bring it up on the
internals mailing list[1].  For the time being, I'm suspending
this ticket.

[1] <https://www.php.net/mailing-lists.php#internals>


Previous Comments:
------------------------------------------------------------------------
[2012-10-14 20:08:50] klaussantana at gmail dot com

Description:
------------
New functionalities for basename().

Syntax:
basename( mixed $path[, mixed $suffix = null[, bool $case_sensitive = false]] );

Summary:
basename() will return the base name of the last component of the path. If it is 
a file name the function will return the name of the file. If it is a directory 
the function will return the name of the directory.

The $path parameter accepts a string or an array of strings to extract the base 
name of the last component of the path.

The $suffix parameter accepts a string or an array of strings to be compared 
against each $path value.

The $case_sensitive parameter accepts a boolean value (true or false) that 
indicates if the $path and $suffix must be compared using "case sensitive" or 
"case insensitive" comparison method.

Return value:
A single string or an array of strings with the base name of the last component 
of the corresponding string stripping $suffix from it.

NOTE:
By default, the function will use "case insensitive" comparison method.

Test script:
---------------
$Files = array();

$Files[] = 'path/to/images/my-computer.jpg';
$Files[] = 'path/to/images/My-Dog.Jpeg';
$Files[] = 'path/to/images/loading.gif';
$Files[] = 'path/to/images/sketch.bmp';

// Overwriting the array
$Files = basename( $Files, array('.bmp', '.jpg', '.jpeg',
'.gif', '.png') );

print_r($Files);

Expected result:
----------------
Array
(
    [0] => my-computer
    [1] => My-Dog
    [2] => loading
    [3] => sketch
)

Actual result:
--------------
null


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=63279&edit=1


Thread (2 messages)

« previous php.bugs (#225891) next »