/**
 _____    _    _   _____    ______                                           _
 |  __ \  | |  | | |  __ \  |  ____|                                         | |
 | |__) | | |__| | | |__) | | |__ _ __ __ _ _ __ ___   _____      _____  _ __| | __
 |  ___/  |  __  | |  ___/  |  __| '__/ _` | '_ ` _ \ / _ \ \ /\ / / _ \| '__| |/ /
 | |      | |  | | | |  _   | |  | | | (_| | | | | | |  __/\ V  V / (_) | |  |   <
 |_|      |_|  |_| |_| (_)  |_|  |_|  \__,_|_| |_| |_|\___| \_/\_/ \___/|_|  |_|\_\
 
 
 Copyright (c) 2016 Wesley de Groot (http://www.wesleydegroot.nl), WDGWV (http://www.wdgwv.com)
 
 
 Variable prefixes:
 PFS = PHP.Framework Shared
 PFT = PHP.Framework Tests (internal)
 PFI = PHP.Framework Internal
 PFU = PHP.Framework Unspecified
 
 usage:
 php.the_php_function(and, parameters, ofcourse)
 
 documentation:
 http://wdg.github.io/php.framework/
 
 wiki:
 https://github.com/wdg/php.framework/wiki
 
 questions/bugs:
 https://github.com/wdg/php.framework/issues
 
 ---------------------------------------------------
 File:    PHPFrameworkArrayFunctions.swift
 Created: 21-JAN-2016
 Creator: Wesley de Groot | g: @wdg | t: @wesdegroot
 Issue:   #4 (Array Functions)
 Prefix:  PFA
 ---------------------------------------------------
 */

import Foundation

/**
 PHPFramework

 A Swift framework inspired by some PHP Functions.
 */
extension PHPFramework {
	/**
	 Changes the case of all keys in an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_change_key_case(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Split an array into chunks (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_chunk(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Return the values from a single column in the input array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_column(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Creates an array by using one array for keys and another for its values (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_combine(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Counts all the values of an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_count_values(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the difference of arrays with additional index check (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_diff_assoc(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the difference of arrays using keys for comparison (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_diff_key(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the difference of arrays with additional index check which is performed by a user supplied callback function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_diff_uassoc(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the difference of arrays using a callback function on the keys for comparison (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_diff_ukey(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the difference of arrays (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_diff(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Fill an array with values, specifying keys (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_fill_keys(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Fill an array with values (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_fill(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Filters elements of an array using a callback function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_filter(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Exchanges all keys with their associated values in an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_flip(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the intersection of arrays with additional index check (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_intersect_assoc(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the intersection of arrays using keys for comparison (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_intersect_key(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the intersection of arrays with additional index check, compares indexes by a callback function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_intersect_uassoc(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the intersection of arrays using a callback function on the keys for comparison (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_intersect_ukey(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the intersection of arrays (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_intersect(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Checks if the given key or index exists in the array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_key_exists(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Return all the keys or a subset of the keys of an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_keys(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Applies the callback to the elements of the given arrays (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_map(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Merge two or more arrays recursively (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_merge_recursive(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Merge one or more arrays (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_merge(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort multiple or multi-dimensional arrays (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_multisort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Pad array to the specified length with a value (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_pad(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Pop the element off the end of array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_pop(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Calculate the product of values in an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_product(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Push one or more elements onto the end of array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_push(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Pick one or more random entries out of an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_rand(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Iteratively reduce the array to a single value using a callback function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_reduce(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Replaces elements from passed arrays into the first array recursively (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_replace_recursive(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Replaces elements from passed arrays into the first array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_replace(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Return an array with elements in reverse order (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_reverse(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Searches the array for a given value and returns the corresponding key if successful (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_search(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Shift an element off the beginning of array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_shift(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Extract a slice of the array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_slice(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Remove a portion of the array and replace it with something else (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_splice(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Calculate the sum of values in an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_sum(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the difference of arrays with additional index check, compares data by a callback function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_udiff_assoc(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the difference of arrays with additional index check, compares data and indexes by a callback function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_udiff_uassoc(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the difference of arrays by using a callback function for data comparison (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_udiff(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the intersection of arrays with additional index check, compares data by a callback function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_uintersect_assoc(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the intersection of arrays with additional index check, compares data and indexes by separate callback functions (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_uintersect_uassoc(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Computes the intersection of arrays, compares data by a callback function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_uintersect(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Removes duplicate values from an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_unique(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Prepend one or more elements to the beginning of an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_unshift(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Return all the values of an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_values(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Apply a user function recursively to every member of an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_walk_recursive(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Apply a user supplied function to every member of an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array_walk(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Create an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func array(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array in reverse order and maintain index association (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func arsort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array and maintain index association (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func asort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Create array containing variables and their values (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func compact(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Count all elements in an array, or something in an object

	 - Parameter arr: The Array<Any>

	 - Returns: Integer of array count
	 */
	public func count(_ arr: Array<Any>) -> Int {
		return arr.count
	}
	
	/**
	 Count all elements in an array, or something in an object

	 - Parameter dict: Dictionary<String, Any>

	 - Returns: Integer of Dictionary count
	 */
	public func count(_ dict: Dictionary<String, Any>) -> Int {
		return dict.count
	}
	
	/**
	 Return the current element in an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func current(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Return the current key and value pair from an array and advance the array cursor (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func each(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Set the internal pointer of an array to its last element

	 - Parameter arr: The Array<Any>

	 - Returns: the element on the last position
	 */
	public func end(_ arr: Array<Any>) -> Any {
		return arr[arr.count]
	}
	
	/**
	 Set the internal pointer of an Dictionary to its last element

	 - Parameter dict: Dictionary<String, Any>

	 - Returns: the element on the last position
	 */
	public func end(_ dict: Dictionary<String, Any>) -> Any {
        return Array(dict.values).last ?? Bool(false) as Any
	}
	
	/**
	 Import variables into the current symbol table from an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func extract(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Checks if a value exists in an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func in_array(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Alias of array_key_exists (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func key_exists(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Fetch a key from an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func key(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array by key in reverse order (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func krsort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array by key (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func ksort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Assign variables as if they were an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func list(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array using a case insensitive "natural order" algorithm (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func natcasesort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array using a "natural order" algorithm (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func natsort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Advance the internal array pointer of an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func next(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Alias of current (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func pos(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Rewind the internal array pointer (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func prev(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Create an array containing a range of elements (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func range(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Set the internal pointer of an array to its first element (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func reset(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array in reverse order (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func rsort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Shuffle an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func shuffle(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Alias of count

	 - Parameter arr: The Array<Any>

	 - Returns: Integer of array count
	 */
	public func sizeof(_ arr: Array<Any>) -> Int {
		return php.count(arr)
	}
	
	/**
	 Alias of count

	 - Parameter dict: Dictionary<String, Any>

	 - Returns: Integer of Dictionary count
	 */
	public func sizeof(_ dict: Dictionary<String, Any>) -> Int {
		return php.count(dict)
	}
	
	/**
	 Sort an array (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func sort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array with a user-defined comparison function and maintain index association (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func uasort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array by keys using a user-defined comparison function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func uksort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
	
	/**
	 Sort an array by values using a user-defined comparison function (**Not Done**)

	 - Parameter arr: The Array<String>

	 - Returns: Something
	 */
	public func usort(_ arr: Array<String>) -> Any {
		print("Sorry this function is not done")
		return false
	}
}
