1. Go to this page and download the library: Download spatie/array-functions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spatie / array-functions example snippets
/**
* Get a random value from an array.
*
* @param array $array
* @param int $numReq The amount of values to return
* @return mixed
*/
function array_rand_value(array $array, $numReq = 1)
/**
* Get a random value from an array, with the ability to skew the results.
* Example: array_rand_weighted(['foo' => 1, 'bar' => 2]) has a 66% chance of returning bar.
*
* @param array $key
*
* @return mixed
*/
function array_rand_weighted(array $array)
/**
* Determine if all given needles are present in the haystack.
*
* @param array|string $needles
* @param array $haystack
*
* @return bool
*/
function values_in_array($needles, array $haystack)
/**
* Determine if all given needles are present in the haystack as array keys.
*
* @param array|string $needles
* @param array $haystack
*
* @return bool
*/
function array_keys_exist($needles, array $haystack)
/**
* Returns an array with two elements.
*
* Iterates over each value in the array passing them to the callback function.
* If the callback function returns true, the current value from array is returned in the first
* element of result array. If not, it is return in the second element of result array.
*
* Array keys are preserved.
*
* @param array $array
* @param callable $callback
* @return array
*
*/
function array_split_filter(array $array, callable $callback)
/**
* Split an array in the given amount of pieces.
*
* @param array $array
* @param int $numberOfPieces
* @param bool $preserveKeys
* @throws \InvalidArgumentException
* @return array
*/
function array_split(array $array, $numberOfPieces = 2, $preserveKeys = false)
/**
* Returns an array with the unique values from all the given arrays
*
* @param \array[] $arrays
* @return array
*/
function array_merge_values(array ... $arrays)
/**
* Flatten an array of arrays. The `$levels` parameter specifies how deep you want to
* recurse in the array. If `$levels` is -1, the function will recurse infinitely.
*
* @param array $array
* @param int $levels
*
* @return array
*/
function array_flatten(array $array, $levels = -1)
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.