PHP code example of hanshinabingdon / linqinp

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

    

hanshinabingdon / linqinp example snippets


use Linqinp\Linqinp;

$target = [1, 2, 3];

// sample01 = [2, 4, 6];
$sample01 = Linqinp::from($target)
  ->select(
    function (int $value) {
      return $value * 2;
    }
  )->toArray();

// sample02 = [1, 4, 9];
$sample02 = Linqinp::from($target)
  ->select(
    function (int $value, int $key) {
      return $value * $key;
    }
  )->toArray();

// sample03 = [1 => 1, 2 => 2, 3 => 3];
$sample03 = Linqinp::from($target)
  ->select(
    function (int $value, int &$key) {
      $key += 1;
      return $value;
    }
  )->toArray();