PHP code example of codeies / json-query

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

    

codeies / json-query example snippets




use Codeies\JsonQuery\JsonQuery;

// Create a new instance of JsonQuery
$jsonQuery = new JsonQuery('path/to/your/data.json');

// Find method
$results = $jsonQuery->find('searchValue')
                    ->sort('category', 'desc')
                    ->paginate($page, $perPage)
                    ->getData();

find($value)
Searches for the specified value within the JSON data.

sort($key, $order = 'asc')
Sorts the filtered data by the specified key and order.

paginate($page, $perPage)
Paginates the filtered data based on the specified page number and items per page.

getData()
Returns the filtered and paginated data.