-4

値の配列に基づいてグループキーを持つ配列を作成したいと思います。

たとえば、次の配列があります。

array(17) { 
    ["user-insert-resp.php"]=> string(3) "123" 
    ["login.php"]=> string(3) "123" 
    ["project-list.php"]=> string(3) "123" 
    ["logout.php"]=> string(3) "123" 
    ["index.php"]=> string(3) "123" 
    ["project-view.php"]=> string(2) "13" 
    ["download.php"]=> string(2) "13" 
    ["sip-creator-resp.php"]=> string(2) "23" 
    ["project-remove-resp.php"]=> string(1) "2" 
    ["statistic.php"]=> string(2) "23" 
    ["graficoUsers.php"]=> string(2) "23" 
    ["statistic-topD.php"]=> string(2) "23" 
    ["statistic-topV.php"]=> string(2) "23" 
    ["user-edit-resp.php"]=> string(1) "3" 
    ["statistic-proj.php"]=> string(1) "3" 
    ["statistic-disc.php"]=> string(1) "3" 
    ["graficodisc.php"]=> string(1) "3" 
}

そして、次のような別の配列を作成したい:

123 => ["user-insert-resp.php","login.php","project-list.php","logout.php","sip-creator-resp.php"]
13 => ["project-view.php","download.php"]
23 => ["sip-creator-resp.php","statistic.php","statistic-topD.php","statistic-topV.php"]
2 => ["project-remove-resp.php"];
3 => ["statistic-proj.php","statistic-disc.php","graficodisc.php"]
4

2 に答える 2

0

http://php.net/manual/en/function.array-flip.phparray_flip()で簡単に見つけることができます。

于 2013-09-27T00:02:33.103 に答える