Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • array_add,array_divide,array_sort Function in laravel 4.x

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 142
    Comment on it

    array_add :

    array_add function is used to add a key/value pair to the array.It will add only when there is no such key available in the existing array

    Example:

    $array = array('foo' => 'bar');
    
    $array = array_add($array, 'key', 'value');
    

    array_divide:

    The array_divide function returns 2 arrays .First array will return the keys and second array will return the value of original array.

    Example:

    $array = array('foo' => 'bar');
    
    list($keys, $values) = array_divide($array);
    
    array_sort:
    

    array_sort:

    The array_sort function is used to sort the array from given array.

    Example:

    $array = array(
        array('name' => 'Jill'),
        array('name' => 'Barry'),
    );
    
    $array = array_values(array_sort($array, function($value)
    {
        return $value['name'];
    }));
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: