Skip to content

Instantly share code, notes, and snippets.

View dazz's full-sized avatar

Anne-Julia Seitz dazz

View GitHub Profile
var_dump(json_encode(
array()
));
// [ ]
var_dump(json_encode(
array('foo')
));
// ["foo"]
@dazz
dazz / print_pre.php
Created September 25, 2013 14:40
pretty print
function print_pre($var, $doDie = true) {
echo "<pre>";
print_r($var);
echo "</pre>";
if ($doDie) {
die('i-die');
}
}
<?php
$tests = array(
array('{"test":""}', 2),
array('{"test": {}}', 3),
array('{"test": {}, "test2": ""}', 3),
array('{"test": {}, "test2": {}}', 3),
array('{"test": {}, "test2": {"test3": ""}}', 3),
array('{"test": {}, "test2": {"test3": {}}}', 4),

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer

<?php
/**
* Class casting
*
* @param string|object $destination
* @param object $sourceObject
* @return object
*/
function cast_long($destination, $sourceObject)