Skip to content

Instantly share code, notes, and snippets.

@boekkooi
boekkooi / deep_copy
Created November 28, 2014 09:35
Deep copy Array
<?php
function arrayCopy(array $array)
{
$hashList = array();
$iterator = new \RecursiveIteratorIterator(
new \RecursiveArrayIterator($array),
\RecursiveIteratorIterator::SELF_FIRST
);
$iterator->rewind();
@boekkooi
boekkooi / gist:abdd30d472b7b6bd3227
Created November 26, 2014 09:03
RFC3261 Uri Regex
<?php
const SIP_PATTERN = '~^
(?:(?<schema>sip(s)?):)?
(?:
(?<user>(?:[a-z0-9\-_\.!\~*\'\(\)]|%[0-9a-f]{2}|[&=\+$,;?\/])+) # user ( unreserved / escaped / user-unreserved )
(?::(?<password>(?:[a-z0-9\-_\.!\~*\'\(\)]|%[0-9a-f]{2}|[&=\+$,])+))? # password ( unreserved / escaped / "&" / "=" / "+" / "$" / "," )
@)? # userinfo
(?<host>
(?:[\pL\pN\pS-\.])+(?:\.?(?:[\pL]|xn\-\-[\pL\pN-]+)+\.?) # a domain name
| # or
@boekkooi
boekkooi / Regex
Last active August 29, 2015 14:09
PHP RFC3986 regex
<?php
const PATTERN_RFC3986 = '~^
(?<scheme>[a-z][a-z0-9+-\.]*)
://
(?:
(?<userinfo>
([a-z0-9\-\._\~!\$&\'()*+,;=:]|%[0-9a-f]{2})*
)@ # *( unreserved / pct-encoded / sub-delims / ":" )
)?