xxxxxxxxxx
//count — Count all elements in an array, or something in an object
count ( mixed $array_or_countable [, int $mode = COUNT_NORMAL ] ) : int
//array_push — Push one or more elements onto the end of array
array_push ( array &$array [, mixed $ ] ) : int
//array_merge — Merge one or more arrays
array_merge ( array $array1 [, array $ ] ) : array
//array_values — Return all the values of an array
array_values ( array $array ) : array
//array_column — Return the values from a single column in the input array
array_column ( array $input , mixed $column_key [, mixed $index_key = NULL ] ) : array
//SEARCHING FUNCTIONS =============================================================================================
//array_search — Searches the array for a given value and returns the first corresponding key if successful
array_search ( mixed $needle , array $haystack [, bool $strict = FALSE ] ) : mixed
//in_array — Checks if a value exists in an array
in_array ( mixed $needle , array $haystack [, bool $strict = FALSE ] ) : bool
//SORTING FUNCTIONS https://php.net/manual/en/array.sorting.php ===================================================
//asort — Sort an array and maintain index association
//arsort — Sort an array in reverse order and maintain index association
asort ( array &$array [, int $sort_flags = SORT_REGULAR ] ) : bool
//usort — Sort an array by values using a user-defined comparison function
//also for sorting multidimensional arry by the value of one specified key (needs separate compare function)
usort ( array &$array , callable $value_compare_func ) : bool
//SORTING A MULTIDIMENSIONAL ASSOCIATIVE ARRAY ON A KEY VALUE
//$array =[
['user' => value1, 'filename' => value2],
['user' => value3, 'filename' => value4]
]
//sort array on user key, ascending
array_multisort(array_column($array, 'user'), SORT_ASC, $array);
//$array with elements which have colour property
//find item by property value
$array=[ ['id' =>1, 'colour'=>'white'], ['id' =>2, 'colour'=>'black']];
$key = array_search('white, array_column($array, 'colour'));
echo $key; // displays 0