Skip to content

Instantly share code, notes, and snippets.

View dodopok's full-sized avatar

Douglas Araujo dodopok

View GitHub Profile
@dodopok
dodopok / gist:5057291
Last active December 14, 2015 08:19
Array2XML
<?php
class ArrayToXML
{
/**
* The main function for converting to an XML document.
* Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
*
* @param array $data
* @param string $rootNodeName - what you want the root node to be - defaultsto data.
* @param SimpleXMLElement $xml - should only be used recursively
@dodopok
dodopok / gist:5038994
Created February 26, 2013 14:55
Formatar Strings PHP para qualquer formato
<?php
function __format($campo='',$mascara=''){
//remove qualquer formatação que ainda exista
$sLimpo = preg_replace("(/[' '-./ t]/)",'',$campo);
// pega o tamanho da string e da mascara
$tCampo = strlen($sLimpo);
$tMask = strlen($mascara);
if ( $tCampo > $tMask ) {
$tMaior = $tCampo;