PHP code example of simondevelop / array-organize

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

    

simondevelop / array-organize example snippets



// index.php
rrayOrganize;

$data = [
  ["id" => 2, "name" => "example 5"],
  ["id" => 1, "name" => "example 5"],
  ["id" => 3, "name" => "example 3"],
  ["id" => 6, "name" => "example 5"],
  ["id" => 5, "name" => "example 3"],
  ["id" => 4, "name" => "example 6"],
  ["id" => 7, "name" => "example 6"],
  ["id" => 8, "name" => "example 7"],
  ["id" => 9, "name" => "example 7"],
  ["id" => 10, "name" => "example 5"]
];

if (isset($_GET['p'])) {
  $page = $_GET['p'];
} else {
  $page = 1;
}

// Init object with data, number by page and current page number
$obj = new ArrayOrganize($data, 3, $page);

// Sort data
$obj->dataSort("id", "ASC");

// Filter data
// $obj->dataFilter(["name" => "example 5"]);

// Css class for the table balise (example with bootstrap 4)
$cssClass = ['table', 'table-striped'];

// Settings of pagination
$pager = [
  "position" => "bottom",
  "lang" => [
    "previous" => "<< Previous",
    "next" => "Next >>"
  ],
  "cssClass" => [
    "ul" => "pagination",
    "li" => "page-item",
    "a" => "page-link",
    "disabled" => [
      "li" => "disabled"
    ],
    "active" => [
      "li" => "active"
    ]
  ],
  "url" => "index.php?p={}"
];