novia713
12/5/2015 - 12:40 PM

funcPHP::Replacing-Iterator.php

funcPHP::Replacing-Iterator.php

<?php

    /*
     * all it's done with iterators
     * can be done with array_map,
     * array_filter & array_reduce
     */

    $text = "Hellow world!";

    $_ = array_filter(str_split($text),
        function($letter) {
            return
                (in_array($letter, ['a','e','i','o','u']))?
                    true:false;
        }
    );

    print_r($_);