SpamBlocker

Spam Blocker is a CakePHP Behavior that automatically before after a comment is made. Each comment is tested upon a point system to determine if it should be approved, set to pending (high points), or marked as spam / deleted (low points).

Listing

Creates a comma seperated list with the last item having an "and".

Function: listing()
Category: PHP
Views: 748
Permalink - Tinylink

/**
 * Creates a comma seperated list with the last item having an "and"
 * @param array $items
 * @param string $and
 * @return string
 */
function listing($items, $and = 'and') {
	if (is_array($items)) {
		$lastItem = array_pop($items);
		$items = implode(', ', $items);
		$items = $items .' '. $and .' '. $lastItem;
	}
 
	return $items;
}

Return to Snippets