public function getNameAndExtension($name)
	{
		static $extensions = array('js', 'html', 'css', 'txt',
			'png', 'gif', 'jpg', 'jpeg',
			'eot', 'svc', 'woff', 'woff2','otf', 'ttf','svg');

		$filename_parts = explode('.', $name);
		$name_parts = array();
		$filters = array();

		/**
		 * NOTE:
		 * if at some moment, there's a need to allow files with extensions in name
		 * (ie sugar.js.min.js), just put the loop backward :
		 * read filters until in_array(), then slice parts to get $name
		 */

		foreach ($filename_parts as $i => $p)
		{
			//cannot be the name
			if ($i != 0 && in_array($p, $extensions))
			{
				$type = $p;
				break;
			}

			if (isset($type)) // we're collecting extensions
				; // TODO: collect extensions
			else
				$name_parts[] = $p;
		}

		$name = implode('.', $name_parts);

		if (!isset($type))
			$type = $filename_parts[1];

		return array($name, $type, $i);
	}
public function getNameAndExtension($name)
	{
		static $extensions = array('js', 'html', 'css', 'txt',
			'png', 'gif', 'jpg', 'jpeg',
			'eot', 'svc', 'woff', 'woff2','otf', 'ttf','svg');

		$filename_parts = explode('.', $name);
		$name_parts = array();
		$filters = array();

		/**
		 * NOTE:
		 * if at some moment, there's a need to allow files with extensions in name
		 * (ie sugar.js.min.js), just put the loop backward :
		 * read filters until in_array(), then slice parts to get $name
		 */

		foreach ($filename_parts as $i => $p)
		{
			//cannot be the name
			if ($i != 0 && in_array($p, $extensions))
			{
				$type = $p;
				break;
			}

			if (isset($type)) // we're collecting extensions
				; // TODO: collect extensions
			else
				$name_parts[] = $p;
		}

		$name = implode('.', $name_parts);

		if (!isset($type))
			$type = $filename_parts[1];

		return array($name, $type, $i);
	}
public function getNameAndExtension ( $ name ) { static $ extensions = array ( 'js' , 'html' , 'css' , 'txt' , 'png' , 'gif' , 'jpg' , 'jpeg' , 'eot' , 'svc' , 'woff' , 'woff2' , 'otf' , 'ttf' , 'svg' ) ; $ filename_parts = explode ( '.' , $ name ) ; $ name_parts = array ( ) ; $ filters = array ( ) ; /**
		 * NOTE:
		 * if at some moment, there's a need to allow files with extensions in name
		 * (ie sugar.js.min.js), just put the loop backward :
		 * read filters until in_array(), then slice parts to get $name
		 */ foreach ( $ filename_parts as $ i => $ p ) { //cannot be the name
 if ( $ i != 0 && in_array ( $ p , $ extensions ) ) { $ type = $ p ; break ; } if ( isset ( $ type ) ) // we're collecting extensions
 ; // TODO: collect extensions
 else $ name_parts [ ] = $ p ; } $ name = implode ( '.' , $ name_parts ) ; if ( ! isset ( $ type ) ) $ type = $ filename_parts [ 1 ] ; return array ( $ name , $ type , $ i ) ; }
reads name and extension for a file name

@example getNameAndExtension('jQuery.datatables.js.coffee.php')
=> ['jQuery.datatables', 'js', ['php', 'coffee']]
@todo I'd like to avoid hardcoding every single extension I may need at some point.
the easiest must be if (!$type) $type = $filename_parts[1];
reads name and extension for a file name