PHP code example of wmde / iterable-functions

1. Go to this page and download the library: Download wmde/iterable-functions 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/ */

    

wmde / iterable-functions example snippets


function doStuff(iterable $iterable) {
    $iterableMinusFooBar = array_diff( $iterable, [ 'foo', 'bar' ] );
}
// Output: array_diff(): Argument #1 is not an array

function doStuff(iterable $iterable) {
    $iterableMinusFooBar = array_diff( iterable_to_array( $iterable ), [ 'foo', 'bar' ] );
}

function doStuff(iterable $iterable) {
    $firstFewThings = new LimitIterator( iterable_to_iterator( $iterable ), 42 );
}