Skip to content

Instantly share code, notes, and snippets.


Leo Toneff bragle

View GitHub Profile
bragle / sanitize-with-breakpoint.php
Created May 11, 2019 22:53
Sanitize multi dimensional PHP arrays
View sanitize-with-breakpoint.php
// Only the first parameter is necessary. The other two are there because of the recursion :)
function sanitizeArray (array $array, array &$output = [], $breakpoint = 0) {
foreach($array as $key => $val){
if(++$breakpoint > 1000){
return false;
bragle / example.php
Created June 23, 2019 11:38
A singleton class loader. Will convert static calls to nonstatic calls and construct the class only when needed. Use this with caution, as it may make your code less readable.
View example.php
# before
# after
# Notice: All functions in the extended class must be protected.