PHP code example of alex_vasechkin / common-helpers
1. Go to this page and download the library: Download alex_vasechkin/common-helpers 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/ */
alex_vasechkin / common-helpers example snippets
use Helpers\CommonHelpers as ch;
$dict = [
'order_id' => '122',
'delivery_id' => '1'
];
$orderId = (int) ch::getArrayValue('order_id', $dict, 0);
use Helpers\CommonHelpers as ch;
use Filters\ColorHandler as ColorFilter;
$filters = [];
// var_dump($_GET['filter_colors']);
// after json_decode:
// [
// 0 => 'green',
// 1 => 'blue'
// ...
// ]
...
// try to convert json format, returns empty array as default value
$filters['colors'] = ch::fromJSON(ch::getArrayValue('filter_colors', $_GET, []));
...
// get first color in colors. Sets empty string as default value
$firstColor = (int) ch::getFirstValue('colors', $filters, '');
// run filter by first color if necessary
if (ch::isFilledString($firstColor)) {
/** @var FilterHandlerInterface $filter */
$filterInstance = new ColorFilter();
$idSet = $filterInstance->runFilter($firstColor);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.