CodeIgniter Forums
Add a function to the array helper - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: Add a function to the array helper (/showthread.php?tid=70359)



Add a function to the array helper - Elias - 03-30-2018

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




RE: Add a function to the array helper - InsiteFX - 03-30-2018

You can add it yourself.

Just create a MY_array_helper.php and add your method to it.


RE: Add a function to the array helper - Elias - 03-30-2018

(03-30-2018, 12:48 PM)InsiteFX Wrote: You can add it yourself.

Just create a MY_array_helper.php and add your method to it.

Yes, I understand it. But I think that this function can be helpful for CI community and this topic can generate new helpful ideas for CI helpers.


RE: Add a function to the array helper - InsiteFX - 03-31-2018

Then you should post it in the CodeIgniter 3X forum topics.