f::name PHP Method

name() static public method

Extracts the name from a file path or filename without extension
static public name ( $name, boolean $remove_path = false ) : string
$remove_path boolean remove the path from the name
return string
    static function name($name, $remove_path = false)
    {
        if ($remove_path == true) {
            $name = self::filename($name);
        }
        $dot = strrpos($name, '.');
        if ($dot) {
            $name = substr($name, 0, $dot);
        }
        return $name;
    }

Usage Example

Example #1
0
 function crawl()
 {
     $path = url::strip_query($this->raw);
     $path = (array) str::split($path, '/');
     if (a::first($path) == 'index.php') {
         array_shift($path);
     }
     // parse params
     foreach ($path as $p) {
         if (str::contains($p, ':')) {
             $parts = explode(':', $p);
             if (count($parts) < 2) {
                 continue;
             }
             $this->params->{$parts}[0] = $parts[1];
         } else {
             $this->path->_[] = $p;
         }
     }
     // get the extension from the last part of the path
     $this->extension = f::extension($this->path->last());
     if ($this->extension != false) {
         // remove the last part of the path
         $last = array_pop($this->path->_);
         $this->path->_[] = f::name($last);
     }
     return $this->path;
 }
All Usage Examples Of f::name