Base::split PHP Méthode

split() public méthode

Split comma-, semi-colon, or pipe-separated string
public split ( $str, $noempty = TRUE ) : array
$str string
$noempty bool
Résultat array
    function split($str, $noempty = TRUE)
    {
        return array_map('trim', preg_split('/[,;|]/', $str, 0, $noempty ? PREG_SPLIT_NO_EMPTY : 0));
    }

Usage Example

Exemple #1
0
 /**
  * add an asset
  * @param string $path
  * @param string $type
  * @param string $group
  * @param int $priority
  * @param string $slot
  * @param array $params
  */
 public function add($path, $type, $group = 'head', $priority = 5, $slot = null, $params = null)
 {
     if (!isset($this->assets[$group])) {
         $this->assets[$group] = array();
     }
     if (!isset($this->assets[$group][$type])) {
         $this->assets[$group][$type] = array();
     }
     $asset = array('path' => $path, 'type' => $type, 'slot' => $slot, 'origin' => '') + ($params ?: array());
     if (preg_match('/^(http(s)?:)?\\/\\/.*/i', $path)) {
         $asset['origin'] = 'external';
         $this->assets[$group][$type][$priority][] = $asset;
         return;
     }
     foreach ($this->f3->split($this->f3->get('UI')) as $dir) {
         if (is_file($view = $this->f3->fixslashes($dir . $path))) {
             $asset['path'] = ltrim($view, './');
             $asset['origin'] = 'internal';
             $this->assets[$group][$type][$priority][] = $asset;
             return;
         }
     }
     // file not found
     if ($handler = $this->f3->get('ASSETS.onFileNotFound')) {
         $this->f3->call($handler, array($path, $this));
     }
     $this->assets[$group][$type][$priority][] = $asset;
 }