function print_r_for_comments($variable, $return = false)
{
$output = trim(print_r($variable, true));
// Pull open round bracket to previous line
$output = preg_replace('/\r?\n *\(/', ' (', $output);
// Remove empty lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Callback that makes unique the items of an array. | |
* | |
* Example usage: | |
* var myArray = ['a', 1, 'a']; | |
* var myUniqueArray = myArray.filter(onlyUnique); | |
* | |
* @param arrayItem one of the items of the array | |
* @param {number} arrayIndex | |
* @param {Array} arrayToMakeUnique |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get raw HTTP request. | |
* | |
* Inspired by: | |
* - https://gist.github.com/magnetikonline/650e30e485c0f91f2f40 | |
* - https://www.php.net/manual/en/function.getallheaders.php#104307 | |
* | |
* @return string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Calculate IBAN check digits (WITHOUT bcmath EXTENSION). | |
* | |
* Inspired by https://github.com/arhs/iban.js/blob/master/iban.js | |
* | |
* @param string $countryCode ISO 3166 2-letter country code, e.g. "FR" | |
* @param string $bban IBAN without country code and without check digits, e.g. "20041010050500013M02606" | |
* | |
* @return string e.g. "14" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Calculate IBAN check digits. | |
* | |
* Inspired by https://github.com/arhs/iban.js/blob/master/iban.js | |
* | |
* @param string countryCode ISO 3166 2-letter country code, e.g. "FR" | |
* @param string bban IBAN without country code and without check digits, e.g. "20041010050500013M02606" | |
* | |
* @return string e.g. "14" | |
*/ |
A BBAN example is X0542811101000000123456, whereas
- X is the checksum (CIN)
- 05428 is the bank code (ABI)
- 11101 is the branch code (CAB)
- 000000123456 is the account number
The only official source describing the checksum computation algorithm, found so far, is http://www.cnb.cz/cs/platebni_styk/iban/download/TR201.pdf , at page 81.
/**
Code:
var year = new Date().getFullYear();
var months = ['01', '02', '03', '04', '05','06', '07', '08', '09', '10', '11', '12'];
var timezones = moment.tz.names();
var dates = months.map(function (month) {
return year + '-'+ month +'-01';
});
var output = {};
Function code:
/**
* Get all the time offsets of a timezone.
*
* @param string $timezoneIdentifier
* @param bool $withDayLightSavingTime
* @return array
*/
function getTimeZoneOffsets(string $timezoneIdentifier, bool $withDayLightSavingTime = true) : array