PHP code example of datashaman / array-filter

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

    

datashaman / array-filter example snippets


array(
  'name' => array( '$present' => true )
)

array(
  'description' => array( '$any' => true )
)

array(
  'tags' => array( '$contains' => array( 'cat', 'animal' ) )
)

array(
  'permissions' => array( '$excludes' => array( 'admin', 'mod' ) )
)

array(
  'gender' => array( '$only' => array( 'male', 'female', 'unknown' ) )
)

array(
  'browser' => array( '$not' => array( 'IE', 'Firefox' ) )
)

array(
  '$matchAny' => array(
    array( 'type' => "Post",
      'state' => array( '$only' => array( 'draft', 'published' ) )
    ),
    array( 'type' => "Comment",
      'state' => array( '$only' => array( 'pending', 'approved', 'spam' ) )
    )
  )
)

array(
  'type' => 'item',
  'user_id' => array( '$query' => 'user.id' )
)

array(
  '$optional' => array( 'description', 'color', 'age' )
)

array(
  'description' => array( '$any' => true ),
  'color' => array( '$any' => true ),
  'age' => array( '$any' => true )
)

use DataShaman\ArrayFilter;

$filter = new ArrayFilter;
$filter->checkFilter($source, $filter, $options);