JBZoo\Utils\Str::slug PHP Method

slug() public static method

Converts any accent characters to their equivalent normal characters
public static slug ( string $text = '', boolean $isCache = false ) : string
$text string
$isCache boolean
return string
    public static function slug($text = '', $isCache = false)
    {
        static $cache = array();
        if (!$isCache) {
            return Slug::filter($text);
        } elseif (!array_key_exists($text, $cache)) {
            // Not Arr::key() for performance
            $cache[$text] = Slug::filter($text);
        }
        return $cache[$text];
    }

Usage Example

コード例 #1
0
ファイル: Checkbox.php プロジェクト: JBZoo/Html
 /**
  * Reload default template.
  *
  * @param string $name
  * @param string $value
  * @param string $id
  * @param string $text
  * @param array $attrs
  * @return string
  */
 protected function _elementTpl($name, $value = '', $id = '', $text = '', array $attrs = array())
 {
     $alias = Str::slug($value, true);
     $inpClass = 'jb-val-' . $alias;
     $input = $this->input($name, $value, $id, $inpClass, $attrs);
     $text = '<span class="label-title">' . $text . '</span>';
     $html = $this->label($id, $alias, $input . $text);
     return '<div class="jb-input jb-checkbox">' . $html . '</div>';
 }
All Usage Examples Of JBZoo\Utils\Str::slug