Friday, July 30, 2010

Where Does Holly Willoughby Get Her Hair Done

PHP Array - Unpivot - Invert Matrix Key Value

Sometimes for some reason can there be the need to "UNPIVOT" a multidimensional array. That switch
:

Array (
[0] => Array
(
[first] => 1
[second] => 2
[third] => 3
[fourth] => 4
)

[1] => Array
(
[first] => 5
[second] => 6
[third] => 7
[fourth] => 8
)

[2] =>
Array (
[first] => 9
[second] => 10
[third] => 11
[fourth] => 12
)
)
to

Array (
[first] => Array
(
[0 ] => 1
[1] => 5
[2] => 9
)

[second] => Array
(
[0] => 2
[1] => 6
[2] => 10
)

[third] => Array
(
[0] => 3
[1] => 7
[2] => 11
)

[fourth] => Array
(
[0] => 4
[1] => 8
[2] => 12
)
)
All thanks to the following function:

0 comments:

Post a Comment