|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-03-04 23:53 UTC] cmb@php.net
-Status: Open
+Status: Suspended
[2020-03-04 23:53 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 09:00:01 2025 UTC |
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