Welcome Guest, Not a member yet? Register   Sign In
Add a function to the array helper
#1
Lightbulb 

Hello CI team and community!

How about add a function to the array helper?

PHP Code:
if ( ! function_exists('array_combine_different'))
{
    
/**
     * Array Combine Different
     *
     * Returns an array combined from two different length arrays
     * with keys as the first array and values as the second array.
     *
     * @param    array
     * @param    array
     * @return    array    combined array
     */
    
function array_combine_different(array $arr1, array $arr2)
    {
        
$length mincount($arr1), count($arr2) );

        
$arr1 array_slice($arr10$length);

        
$arr2 array_slice($arr20$length);

        return 
array_combine($arr1$arr2);
    }

Reply


Messages In This Thread
Add a function to the array helper - by Elias - 03-30-2018, 12:20 PM
RE: Add a function to the array helper - by Elias - 03-30-2018, 01:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB