Paulund

Here is a quick code snippet for flattening a multi-dimensional array using PHP.

This uses the function array_walk_recursive that applies a function to every element of an array. Using this function we can add the value to a new array and return that instance.

function flatten(array $array) {
$return = array();
array_walk_recursive($array, function($a) use (&$return) { $return[] = $a; });
return $return;
}

print_r(flatten([1, 2, [3], [4, [5, 6], 5, 6], [[7], [8, [9]]], 10, [[[11], 12]]]));


Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 5
[7] => 6
[8] => 7
[9] => 8
[10] => 9
[11] => 10
[12] => 11
[13] => 12
)

--

--

The NVM (Node Version Manager) is a script used for installing and managing Node. The macOS users can install NVM using the homebrew.

Use this tutorial to help install NVM on your mac and manage Node.js versions.

First remove the installed node version.

brew uninstall --ignore-dependencies node 
brew uninstall --force…

--

--