PHP code example of toobo / hop

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

    

toobo / hop example snippets


$data = [
  'foo',
  1,
  true,
  'bar',
  [],
  ''
];

$strings = array_filter($data, 'is_string'); // ['foo', 'bar', '']

$strings = array_filter($data, function($item) {
    return is_string($item) && $item !== '';
});

$strings = array_filter($data, Hop\chain(Hop\isType('string'), Hop\isNotEmpty()));