PHP code example of licvido / array-to-table

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

    

licvido / array-to-table example snippets


echo array_to_table($array);

// array of values
$array = ['lorem', 'ipsum', 3, 4, 5, 'dolor', 7];

// or array of arrays without keys
$array = [
	[1, 2],
	[1, 2, 3],
	[1, 4, 3],
	[5, 6],
];

// or array of arrays with keys and values
$array = [
	['A' => 1, 'B' => 2],
	['A' => 3, 'B' => 4],
	['A' => 5, 'B' => 6, 'C' => 7, 'D' => 8],
	['E' => 9, 'F' => 0],
];

// or array of objects
$array = [
	(object) ['A' => 1, 'B' => 2],
	(object) ['A' => 3, 'B' => 4],
	(object) ['A' => 5, 'B' => 6, 'C' => 7, 'D' => 8],
	(object) ['E' => 9, 'F' => 0],
];

// or array of mixed arrays and objects
$array = [
	['A' => 1, 'B' => 2],
	(object) ['A' => 3, 'B' => 4],
	['A' => 5, 'B' => 6, 'C' => 7, 'D' => 8],
	(object) ['E' => 9, 'F' => 0],
];

// or array of objects from json
$dummyData = json_decode(file_get_contents('https://dummyjson.com/users'));
$array = $dummyData->users;



// print table
echo array_to_table($array);