PHP code example of corealg / helper

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

    

corealg / helper example snippets


'MyHelper' => CoreAlg\Helper\Helper::class,


echo MyHelper::paginationSummary(100, 10, 1);
// Output: Showing 1 to 10 of 100 records


echo MyHelper::number2word(100);
// Output: One Hundred Taka Only.


echo MyHelper::formatAmount(10000, 2, '.', ',');
// Output: 10,000.00


// set amount_format into session variable under `core_helper` key (you can do this once after login)
session()->put('core_helper', [
    'amount_format' => [ // you can set this value from database as well
        'decimals' => 3,
        'decimal_separator' => '.',
        'thousands_separator' => ','
    ]
]);
$order = \App\Models\Order::find(1);
echo MyHelper::formatAmount($order->amount);
// Output: 10,000.000


echo MyHelper::formatDate("2021-09-27", "d M, Y");
// Output: 27 Sep, 2021


// set data_format into session variable under `core_helper` key (you can do this once after login)
session()->put('core_helper', [
    'date_format' => 'd M, Y @ h:i:s A (P)' // you can set this value from database as well
]);
$user = \App\Models\User::find(1);
echo MyHelper::formatDate($user->created_at);
// Output: 27 Sep, 2021 @ 03:25:10 PM (+06:00)