$array = [
  [
    'id'     => 1,
    'name'   => 'Jhon doe',
    'city'   => 'New York',
    'Gender' => 'male'
  ],
  ...
];

We have a simple 2D Array

In many cases we got an array of data without using a database, A static Array or even non-parsed data as a Json response... Then we have to filter it!

2D : array( array(),array(),array()... );

SQL-it Simple & Useful Class

We need to filter this Array, that may contain big number of records... by using SQL-it this can be done quickly! & for Json response we can use json_decode() before.

Filtring Array is simple using few methods that looks like an ORM architecture with basic SQL statements.

L'ets fetch all results that have California as city, Selecting 'id','name' columns, order by 'id' ASC, limit 2 results.

use floatPHP\Arrays\SQLit;
$orm = new SQLit($array);
$result = $orm->select(['id','name'])
->where([
  [
    'column' => 'city',
    'value'  => 'California',
    'link'   => 'LIKE'
  ]
])
-order('id')
-limit(2)
-query();

// SELECT `id`, `name`, 
// FROM $array WHERE `city` LIKE 'California'
array (size=2)
  0 => 
    array (size=2)
      'id' => int 3
      'name' => string 'Jhon Parent'
  1 => 
    array (size=2)
      'id' => int 6
      'name' => string 'Alfred Pirtor'

Result : Filtred Array

We got filtred array.

See Documentation

Installation : using composer

composer require jakiboy/sql-it