Skip to content

Instantly share code, notes, and snippets.

View philipnorton42's full-sized avatar
🏠
Working from home

Philip Norton philipnorton42

🏠
Working from home
View GitHub Profile
<?php
function gameOver($snake) {
if ($snake->tail > 5) {
// If the trail is greater than 5 then check for end condition.
for ($i = 1; $i < count($snake->trail); $i++) {
if ($snake->trail[$i][0] == $snake->positionX && $snake->trail[$i][1] == $snake->positionY) {
die('dead :(');
}
}
<?php
function renderGame($state, $activeCell, $player) {
$output = '';
$output .= 'Player:' . $player . PHP_EOL;
foreach ($state as $x => $line) {
$output .= '|';
foreach ($line as $y => $item) {
<?php
function translateKeypress($string) {
switch ($string) {
case "\033[A":
return "UP";
case "\033[B":
return "DOWN";
case "\033[C":
return "RIGHT";
@philipnorton42
philipnorton42 / Config Merge
Last active December 2, 2018 19:31
A stand alone script that can be used to compare and copy configuration from two different sub-sites into a default configuration.
<?php
require './vendor/autoload.php';
// Set up the directories needed.
$parentDirectory = 'config/siteone';
$siblingDirectory = 'config/sitetwo';
$destinationDirectory = 'config/default';
<?php
/**
* Googl
*
* For more information on this file and how to use the class please visit
* http://www.hashbangcode.com/blog/googl-url-shortening-service-class-php-528.html
*
* PHP version 5
*