Instantly share code, notes, and snippets.

View gist:18e130dee507e883bcef
Verifying that +richardpq is my blockchain ID. https://onename.com/richardpq
View validate.php
<?php
$invalidParameters = ['Key_1' => 1, 'Key_2' => 2, 'No_valid' => 3];
$validParameters = ['Key_1' => 1, 'Key_2' => 2];
function validParameters($parameters) {
$validKeys = ['Key_1', 'Key_2', 'Key_3', 'Key_4'];
$keys = array_keys($parameters);
return array_diff($keys, $validKeys) ? false : true;
View factorial.php
<?php
public function factorial($number)
{
if ($number == 1) {
return 1;
}
$total = $number * $this->factorial($number - 1);
return $total;
View magicTrick.php
<?php
$letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U'];
shuffle($letters);
$count = 1;
$message = "";
do {
View SplClassLoader.php
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,