PHP code example of imtiazmahbub / array-to-text-php

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

    

imtiazmahbub / array-to-text-php example snippets




$data = array(
	array('company'=>'AIG', 'id'=>1, 'balance'=> '-$99,999,999,999.00'),
	array('company'=>'Wachovia', 'id'=>2, 'balance'=> '-$10,000,000.00'),
	array('company'=>'HP', 'id'=>3, 'balance'=> '$555,000.000.00'),
	array('company'=>'IBM', 'id'=>4, 'balance'=> '$12,000.00')
);

$renderer = new ArrayToTextTable($data);
$renderer->showHeaders(true);
$renderer->render();

+----------+----+---------------------+
| COMPANY  | ID |       BALANCE       |
+----------+----+---------------------+
| AIG      | 1  | -$99,999,999,999.00 |
| Wachovia | 2  | -$10,000,000.00     |
| HP       | 3  | $555,000.000.00     |
| IBM      | 4  | $12,000.00          |
+----------+----+---------------------+

$output = $renderer->render(true);

$renderer->setMaxWidth(30);

$renderer->setMaxHeight(30);