Inflector::slug PHP Method

slug() public static method

public static slug ( $string, $replace = '-' )
    public static function slug($string, $replace = '-')
    {
        $map = array('/À|à|Á|á|å|Ã|â|Ã|ã/' => 'a', '/È|è|É|é|Ê|ê|ẽ|Ë|ë/' => 'e', '/Ì|ì|Í|í|Î|î/' => 'i', '/Ò|ò|Ó|ó|Ô|ô|ø|Õ|õ/' => 'o', '/Ù|ù|Ú|ú|ů|Û|û|Ü|ü/' => 'u', '/ç|Ç/' => 'c', '/ñ|Ñ/' => 'n', '/ä|æ/' => 'ae', '/Ö|ö/' => 'oe', '/Ä|ä/' => 'Ae', '/Ö/' => 'Oe', '/ß/' => 'ss', '/[^\\w\\s]/' => ' ', '/\\s+/' => $replace, '/^' . $replace . '+|' . $replace . '+$/' => '');
        return strtolower(preg_replace(array_keys($map), array_values($map), $string));
    }

Usage Example

Esempio n. 1
1
 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
  *
  * @param array $settings array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
 public function init($settings = array())
 {
     if (!class_exists('Memcache')) {
         return false;
     }
     if (!isset($settings['prefix'])) {
         $settings['prefix'] = Inflector::slug(APP_DIR) . '_';
     }
     $settings += array('engine' => 'Memcache', 'servers' => array('127.0.0.1'), 'compress' => false, 'persistent' => true);
     parent::init($settings);
     if ($this->settings['compress']) {
         $this->settings['compress'] = MEMCACHE_COMPRESSED;
     }
     if (is_string($this->settings['servers'])) {
         $this->settings['servers'] = array($this->settings['servers']);
     }
     if (!isset($this->_Memcache)) {
         $return = false;
         $this->_Memcache = new Memcache();
         foreach ($this->settings['servers'] as $server) {
             list($host, $port) = $this->_parseServerString($server);
             if ($this->_Memcache->addServer($host, $port, $this->settings['persistent'])) {
                 $return = true;
             }
         }
         return $return;
     }
     return true;
 }
All Usage Examples Of Inflector::slug