PHP code example of pyther / linquo

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

    

pyther / linquo example snippets


$people = [array of peoples];

// give me all adults names in alphabetical order as an array
$names = from($people)
    ->where(fn($e) => $e->age >= 18)   // only persons of 18 or older  
    ->orderBy(fn($e) => $e->name)      // order by name
    ->select(fn($e) => $e->name)       // select the name only 
    ->toArray();                       // convert to array

echo $books
    ->where(fn($e) => $e->year > 1850)  // all books after 1850
    ->orderBy(fn($e) => $e->year)       // sort by year
    ->join(                             // join with ...  
        $authors,                       // ... authors ...
        fn($book) => $book->authorId,   // ... where the books author id ...
        fn($author) => $author->id,     // ... matches the authors id.
        fn($book, $author) => "{$book->title} by {$author->name} in {$book->year}"
    )->toJson();                        // and return as json