Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14343

Add a function to the array helper

$
0
0
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);
    }


Viewing all articles
Browse latest Browse all 14343

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>