PHPMailer\PHPMailer
PHPMailer::mb_pathinfo()
Multi-byte-safe pathinfo replacement. Drop-in replacement for pathinfo(), but multibyte- and cross-platform-safe.
Method of the class: PHPMailer{}
No Hooks.
Return
String|Array
.
Usage
$result = PHPMailer::mb_pathinfo( $path, $options );
- $path(string) (required)
- A filename or path, does not need to exist as a file
- $options(int|string)
- Either a PATHINFO_ constant, or a string name to return only the specified piece
Default: null*
Notes
PHPMailer::mb_pathinfo() PHPMailer::mb pathinfo code WP 6.6.2
public static function mb_pathinfo($path, $options = null) { $ret = ['dirname' => '', 'basename' => '', 'extension' => '', 'filename' => '']; $pathinfo = []; if (preg_match('#^(.*?)[\\\\/]*(([^/\\\\]*?)(\.([^.\\\\/]+?)|))[\\\\/.]*$#m', $path, $pathinfo)) { if (array_key_exists(1, $pathinfo)) { $ret['dirname'] = $pathinfo[1]; } if (array_key_exists(2, $pathinfo)) { $ret['basename'] = $pathinfo[2]; } if (array_key_exists(5, $pathinfo)) { $ret['extension'] = $pathinfo[5]; } if (array_key_exists(3, $pathinfo)) { $ret['filename'] = $pathinfo[3]; } } switch ($options) { case PATHINFO_DIRNAME: case 'dirname': return $ret['dirname']; case PATHINFO_BASENAME: case 'basename': return $ret['basename']; case PATHINFO_EXTENSION: case 'extension': return $ret['extension']; case PATHINFO_FILENAME: case 'filename': return $ret['filename']; default: return $ret; } }