PHP code example of aheenam / laravel-collection-addon

1. Go to this page and download the library: Download aheenam/laravel-collection-addon 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/ */

    

aheenam / laravel-collection-addon example snippets




// returns true
collect([1,2,3])->containsAll([1,2]);

// returns false
collect([1,2,3])->containsAll([1,4]);



// returns true
collect([1,2,3])->containsAny([1,4]);

// returns false
collect([1,2,3])->containsAny([4,5]);



// returns true
collect(['name' => 'john doe', 'nickname' => 'jd', 'age'  => 32])->hasAny(['name', 'nickname']);

// returns false
collect(['name' => 'john doe', 'age' => 32])->hasAny(['name', 'firstName', 'lastName']);

// returns false
collect(['nickname' => 'jd', 'age' => 32])->hasAny(['name', 'firstName', 'lastName']);



// returns true
collect(['name' => 'john doe', 'age' => 32])->hasAny(['name', 'firstName', 'lastName']);

// returns false
collect(['nickname' => 'jd', 'age' => 32])->hasAny(['name', 'firstName', 'lastName']);