Skip to content

Instantly share code, notes, and snippets.

View yeroon's full-sized avatar

Jeroen Schouten yeroon

  • KNMI
  • the Netherlands
View GitHub Profile
@yeroon
yeroon / HttpQueryBuilder.php
Created July 25, 2012 19:48
PHP 5.3 Http QueryString Builder
<?php
namespace Yeroon;
/**
* Build querystring
*
* Build a querystring with add/remove features. Has array support to support adding and removing of params using square
* brackets (?foo[]=bar).
*
@yeroon
yeroon / Simple password function
Created August 23, 2011 14:26
Generate a random password of arbitrary length consisting of lowercased letters, uppercased letters and numbers, except for 'o', 'i', 'l', 'O', 'i' and 1.
/**
* Generate a password of arbitrary length, consisting of lowercased letters,
* uppercased letters and numbers, except for 'o', 'i', 'l', 'O', 'I', and 1.
*
* @param int $length Defaults to 8
* @return string password
*/
function simple_password($length = 8)
{
$exclude = array('o', 'i', 'l', 'O', 'I', 1);
@yeroon
yeroon / simpleXmlToArray
Created April 18, 2011 14:45
Converts a simpleXML element into an array. Preserves attributes and everything.
/**
* Converts a simpleXML element into an array. Preserves attributes and everything.
* You can choose to get your elements either flattened, or stored in a custom index that
* you define.
* For example, for a given element
* <field name="someName" type="someType"/>
* if you choose to flatten attributes, you would get:
* $array['field']['name'] = 'someName';
* $array['field']['type'] = 'someType';
* If you choose not to flatten, you get: