simondevelop / array-organize
Php library for easy sorting of data, generate html table and more.
Installs: 2 546
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 3
Open Issues: 1
Requires
- php: >=7.3
Requires (Dev)
- phpstan/phpstan: ^0.12.94
- phpunit/phpunit: ^9.5.8
- squizlabs/php_codesniffer: 4.0.x-dev
This package is auto-updated.
Last update: 2024-11-29 12:49:17 UTC
README
array-organize
Php library for easy sorting of data, generate html table and more.
composer require simondevelop/array-organize
Example
<?php // index.php require "vendor/autoload.php"; use SimonDevelop\ArrayOrganize; $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={}" ]; ?> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>ArrayOrganize</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous"> </head> <body> <div class="container"> <?php // Generate html table (with pager on second parameter) echo $obj->generateTable($cssClass, $pager); ?> </div> </body> </html>
Check this docs for more.
Go to contribute !
- Check the Code of Conduct
- Check the Contributing file
- Check the Pull Request Template