This snippet includes two functions : one that retrieves an array's longest row length, and another that transposes it according to the title (and depends on the first). It can come handy when needing to access simple data the other way around.

function array_longer_row($array)
{
    $max = 0;
    $lens = array();
    foreach ($array as $row)
    {
        $len = 1;
        if (is_array($row))
            $len = count($row);
        $lens[] = $len;
    }
    return max($lens);
}



function array_transpose($array)
{
    $result = array();
    $max = array_longer_row($array);
    for ($i=0;$i<$max;$i++)
    {
        $result[$i] = array();
        foreach ($array as $key => $row)
        {
            if (is_array($row))
                $row = array_values($row);
            else
                $row = array($row);
            if (isset($row[$i]))
                $result[$i][] = $row[$i];
        }
    }
    return $result;
}