src/Suki/Tools.php
public function commaSeparated($string, $type = 'alphanumeric', $delimiter = ',')
	{
		if (empty($string))
			return false;

		// This is why we can't have nice things...
		$t = isset($this->_commaCases[$type]) ? $this->_commaCases[$type] : $this->_commaCases['alphanumeric'];

		return empty($string) ? false : implode($delimiter, array_filter(explode($delimiter, preg_replace(
			array(
				'/[^'. $t .',]/',
				'/(?<='. $delimiter .')'. $delimiter .'+/',
				'/^'. $delimiter .'+/',
				'/'. $delimiter .'+$/'
			), '', $string
		))));
	}
public function commaSeparated($string, $type = 'alphanumeric', $delimiter = ',')
	{
		if (empty($string))
			return false;

		// This is why we can't have nice things...
		$t = isset($this->_commaCases[$type]) ? $this->_commaCases[$type] : $this->_commaCases['alphanumeric'];

		return empty($string) ? false : implode($delimiter, array_filter(explode($delimiter, preg_replace(
			array(
				'/[^'. $t .',]/',
				'/(?<='. $delimiter .')'. $delimiter .'+/',
				'/^'. $delimiter .'+/',
				'/'. $delimiter .'+$/'
			), '', $string
		))));
	}
public function commaSeparated ( $ string , $ type = 'alphanumeric' , $ delimiter = ',' ) { if ( empty ( $ string ) ) return false ; // This is why we can't have nice things... $ t = isset ( $ this -> _commaCases [ $ type ] ) ? $ this -> _commaCases [ $ type ] : $ this -> _commaCases [ 'alphanumeric' ] ; return empty ( $ string ) ? false : implode ( $ delimiter , array_filter ( explode ( $ delimiter , preg_replace ( array ( '/[^' . $ t . ',]/' , '/(?<=' . $ delimiter . ')' . $ delimiter . '+/' , '/^' . $ delimiter . '+/' , '/' . $ delimiter . '+$/' ) , '' , $ string ) ) ) ) ; }
Checks and returns a comma separated string.
@access public
@param string $string The string to check and format
@param string $type The type to check against. Accepts "numeric", "alpha" and "alphanumeric".
@param string $delimiter Used for explode/imploding the string.
@return string|bool
Checks and returns a comma separated string .