Archive for June, 2009

array_flatten()

How exactly is this function not in the PHP core yet?

function array_flatten($arr) {
$flattened = array();
if (is_array($arr)) {
foreach ($arr as $value) {
$flattened = array_merge($flattened, array_flatten($value));
}
} else {
$flattened[] = $arr;
}

return $flattened;
}

Usage:

$a = array(
‘foo’ => ‘bar’,
‘baz’ => array(1, 2, 3, 4, 5),
‘bat’ => array(
‘a’,
array(
‘b’,
array(
‘c’,
array(‘d’)
)
)
)
);

print_r(array_flatten($a));

/*
Array
(
[0] => bar
[1] => 1
[...]

June 19, 2009   Posted in: php  No Comments

Running a Subversion server on Windows

This needs to be in more places on the internet. I’m sick of googling it every time I can’t remember the stupid command.

Download the zipped up version of Subversion, and put it somewhere, say, c:\lib\svn
Create your subversion repository: c:\lib\svn\bin\svnadmin create c:\path\to\repo
Type this, and the equals sign spacing is extremely intentional:sc create subversion binpath= “c:\lib\svn\bin\svnserve.exe –service [...]

June 16, 2009   Posted in: subversion, windows  No Comments

How Embarrassing

I’m a PHP developer and I just installed Wordpress. That’s like being a castrati and hanging out with all the kids who have penises (think about it).
Best first post ever? All signs point to yes.

June 12, 2009   Posted in: Uncategorized  One Comment