Skip to content

Instantly share code, notes, and snippets.

@zamaldev
zamaldev / combinations.php
Last active December 4, 2020 16:49
Generation of all possible combinations of array elements
<?php
function getIndexCombinations($arValues): array {
$iProduct = 1;
foreach ($arValues as $arSubArray) $iProduct *= count($arSubArray);
$arIndexCombinations = [];
for ($i = 0; $i < $iProduct; $i++) {
$arIndices = [];
@zamaldev
zamaldev / PSR-12.md
Created February 19, 2021 15:35
PSR-12: Extended Coding Style

PSR-12: Extended Coding Style

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.

This specification extends, expands and replaces PSR-2, the coding style guide and requires adherence to PSR-1, the basic coding standard.

Like PSR-2, the intent of this specification is to reduce cognitive friction when scanning code from different authors. It does so by enumerating a shared set of rules and expectations about how to format PHP code. This PSR seeks to provide a set way that coding style tools can implement, projects can declare adherence to and developers can easily relate to between different projects. When various authors collaborate across multiple projects, it helps to have one set of guidelines to be used among