INVP::weekdays( int $zero_through_six = null )

weekdays


Description Description

If no parameter is provided, returns an array containing lowercase weekdays as keys and title case, three-letter abbreviations as values. If a valid parameter is provided, returns the lowercase day name it identifies. If an invalid parameter is provided, returns false.


Top ↑

Parameters Parameters

$zero_through_six

(int) (Optional) A number between 0 and 6 to identify a single day to return as a string.

Default value: null


Top ↑

Return Return

(string|Array|false)


Top ↑

Source Source

File: includes/class-invp.php

	public static function weekdays( $zero_through_six = null )
	{
		$days = array(
			'monday'    => __( 'Mon', 'inventory-presser' ),
			'tuesday'   => __( 'Tue', 'inventory-presser' ),
			'wednesday' => __( 'Wed', 'inventory-presser' ),
			'thursday'  => __( 'Thu', 'inventory-presser' ),
			'friday'    => __( 'Fri', 'inventory-presser' ),
			'saturday'  => __( 'Sat', 'inventory-presser' ),
			'sunday'    => __( 'Sun', 'inventory-presser' ),
		);

		/**
		 * If a valid parameter is provided, return the lowercase day name
		 * it identifies.
		 */
		if( null !== $zero_through_six )
		{
			if( 0 <= $zero_through_six && 6 >= $zero_through_six )
			{
				return array_keys( $days )[$zero_through_six];
			}
			else
			{
				//If an invalid parameter is provided, return false
				return false;
			}
		}

		//Return the array
		return $days;
	}