[英]Dynamically create multi multidimensional array while looping through foreach loop
我的這個數組包含員工角色詳細信息,部門詳細信息和權限詳細信息。
Array
(
[0] => stdClass Object
(
[role_id] => 3
[role_name] => team leader
[role_description] => Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market
[role_department_id] => 2
[department_id] => 2
[department_name] => brand centrical
[department_description] => Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.
[user_role_permission_id] => 13
[user_permission_id] => 9
[permission] => employee
[permission_page] => newemployee
)
[1] => stdClass Object
(
[role_id] => 3
[role_name] => team leader
[role_description] => Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market
[role_department_id] => 2
[department_id] => 2
[department_name] => brand centrical
[department_description] => Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.
[user_role_permission_id] => 15
[user_permission_id] => 11
[permission] => employee
[permission_page] => edit
)
[2] => stdClass Object
(
[role_id] => 3
[role_name] => team leader
[role_description] => Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market
[role_department_id] => 2
[department_id] => 2
[department_name] => brand centrical
[department_description] => Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.
[user_role_permission_id] => 16
[user_permission_id] => 12
[permission] => employee
[permission_page] => update
)
[3] => stdClass Object
(
[role_id] => 3
[role_name] => team leader
[role_description] => Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market
[role_department_id] => 2
[department_id] => 2
[department_name] => brand centrical
[department_description] => Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.
[user_role_permission_id] => 6
[user_permission_id] => 16
[permission] => suggestion
[permission_page] => view
)
[4] => stdClass Object
(
[role_id] => 3
[role_name] => team leader
[role_description] => Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market
[role_department_id] => 2
[department_id] => 2
[department_name] => brand centrical
[department_description] => Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.
[user_role_permission_id] => 7
[user_permission_id] => 18
[permission] => evaluation
[permission_page] => index
)
[5] => stdClass Object
(
[role_id] => 3
[role_name] => team leader
[role_description] => Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market
[role_department_id] => 2
[department_id] => 2
[department_name] => brand centrical
[department_description] => Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.
[user_role_permission_id] => 9
[user_permission_id] => 25
[permission] => leave
[permission_page] => newrequest
)
[6] => stdClass Object
(
[role_id] => 3
[role_name] => team leader
[role_description] => Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market
[role_department_id] => 2
[department_id] => 2
[department_name] => brand centrical
[department_description] => Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.
[user_role_permission_id] => 10
[user_permission_id] => 26
[permission] => leave
[permission_page] => create
)
[7] => stdClass Object
(
[role_id] => 3
[role_name] => team leader
[role_description] => Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market
[role_department_id] => 2
[department_id] => 2
[department_name] => brand centrical
[department_description] => Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.
[user_role_permission_id] => 17
[user_permission_id] => 27
[permission] => leave
[permission_page] => viewall
)
[8] => stdClass Object
(
[role_id] => 3
[role_name] => team leader
[role_description] => Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market
[role_department_id] => 2
[department_id] => 2
[department_name] => brand centrical
[department_description] => Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.
[user_role_permission_id] => 11
[user_permission_id] => 28
[permission] => leave
[permission_page] => response
)
)
在上面的代碼塊中,您可以看到[permission] => employee
對於[0]
, [1]
和[2]
數組也相同。 但是[permission_page]
不同。 因此,我想要一個如下所示的多維數組。 在這里, [permission]
數組包含所有[permission_page]
。 我想以類似下面的方式實現我的代碼。 任何幫助將非常感激。
Array
(
[employee] => Array
(
[0] => newemployee
[1] => edit
[2] => update
)
[suggestion] => Array
(
[0] => view
)
[evaluation] => Array
(
[0] => index
)
[leave] => Array
(
[0] => newrequest
[1] => create
[2] => viewall
[3] => response
)
)
獲取權限和權限頁面的所有值,然后循環訪問權限以獲取分組權限明智頁面。
$permission = array_column($arr, 'permission');
$permission_page = array_column($arr, 'permission_page');
$result = [];
foreach($permission as $k => $v){
$result[$v][] = $permission_page[$k];
}
print_r($result);
array_column —從輸入數組中的單個列返回值
這是工作演示 。
使用foreach
然后將每個permission_page
以permission
作為鍵推送到$result
$result = [];
foreach ($array as $object) {
$result[$object->permission][] = $object->permission_page;
}
echo '<pre>';
print_r($result);
我創建了以下代碼。 希望它可以幫助您。 它提供您想要的確切輸出。
<?php $data = []; $data[] = Array( 'role_id' => 3, 'role_name' => 'team leader', 'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market', 'role_department_id' => 2, 'department_id' => 2, 'department_name' => 'brand centrical', 'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.', 'user_role_permission_id' => 13, 'user_permission_id' => 9, 'permission' => 'employee', 'permission_page' => 'newemployee' ); $data[] = Array( 'role_id' => 3, 'role_name' => 'team leader', 'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market', 'role_department_id' => 2, 'department_id' => 2, 'department_name' => 'brand centrical', 'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.', 'user_role_permission_id' => 15, 'user_permission_id' => 11, 'permission' => 'employee', 'permission_page' => 'edit', ); $data[] = Array( 'role_id' => 3, 'role_name' => 'team leader', 'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market', 'role_department_id' => 2, 'department_id' => 2, 'department_name' => 'brand centrical', 'department_description' =>' Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.', 'user_role_permission_id' => 16, 'user_permission_id' => 12, 'permission' => 'employee', 'permission_page' => 'update', ); $data[] = array ( 'role_id' => 3, 'role_name' => 'team leader', 'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market', 'role_department_id' => 2, 'department_id' => 2, 'department_name' =>' brand centrical', 'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.', 'user_role_permission_id' => 6, 'user_permission_id' => 16, 'permission' => 'suggestion', 'permission_page' => 'view', ); $data[] = array ( 'role_id' => 3, 'role_name' => 'team leader', 'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market', 'role_department_id' => 2, 'department_id' => 2, 'department_name' => 'brand centrical', 'department_description' =>' Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.', 'user_role_permission_id' => 7, 'user_permission_id' => 18, 'permission' => 'evaluation', 'permission_page' => 'index', ); $data[] = array ( 'role_id' => 3, 'role_name' => 'team leader', 'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market', 'role_department_id' => 2, 'department_id' => 2, 'department_name' => 'brand centrical', 'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.', 'user_role_permission_id' => 9, 'user_permission_id' => 25, 'permission' => 'leave', 'permission_page' => 'newrequest', ); $data[] = array ( 'role_id' => 3, 'role_name' => 'team leader', 'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market', 'role_department_id' => 2, 'department_id' => 2, 'department_name' => 'brand centrical', 'department_description' =>' Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.', 'user_role_permission_id' => 10, 'user_permission_id' => 26, 'permission' => 'leave', 'permission_page' => 'create', ); $data[] = array ( 'role_id' => 3, 'role_name' => 'team leader', 'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market', 'role_department_id' => 2, 'department_id' => 2, 'department_name' => 'brand centrical', 'department_description' =>' Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.', 'user_role_permission_id' => 17, 'user_permission_id' => 27, 'permission' => 'leave', 'permission_page' => 'viewall', ); $data[] = array ( 'role_id' => 3, 'role_name' => 'team leader', 'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market', 'role_department_id' => 2, 'department_id' => 2, 'department_name' => 'brand centrical', 'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.', 'user_role_permission_id' => 11, 'user_permission_id' => 28, 'permission' => 'leave', 'permission_page' => 'response', ); foreach($data as $d) { $var = $d['permission']; $data1["'".$var."'"][] = $d['permission_page']; } echo '<pre>';print_r($data1);echo '</pre>';exit; ?>
這是您的解決方案
輸入
<?php
$array = array(
array(
'role_id' => '3',
'role_name' => 'team leader',
'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market',
'role_department_id' => '2',
'department_id' => '2',
'department_name' => 'brand centrical',
'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.',
'user_role_permission_id' => '13',
'user_permission_id' => '9',
'permission' => 'employee',
'permission_page' => 'newemployee'
),
array(
'role_id' => '3',
'role_name' => 'team leader',
'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market',
'role_department_id' => '2',
'department_id' => '2',
'department_name' => 'brand centrical',
'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.',
'user_role_permission_id' => '15',
'user_permission_id' => '11',
'permission' => 'employee',
'permission_page' => 'edit'
),
array(
'role_id' => '3',
'role_name' => 'team leader',
'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market',
'role_department_id' => '2',
'department_id' => '2',
'department_name' => 'brand centrical',
'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.',
'user_role_permission_id' => '16',
'user_permission_id' => '12',
'permission' => 'employee',
'permission_page' => 'update'
),
array(
'role_id' => '3',
'role_name' => 'team leader',
'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market',
'role_department_id' => '2',
'department_id' => '2',
'department_name' => 'brand centrical',
'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.',
'user_role_permission_id' => '6',
'user_permission_id' => '16',
'permission' => 'suggestion',
'permission_page' => 'view'
),
array(
'role_id' => '3',
'role_name' => 'team leader',
'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market',
'role_department_id' => '2',
'department_id' => '2',
'department_name' => 'brand centrical',
'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.',
'user_role_permission_id' => '7',
'user_permission_id' => '18',
'permission' => 'evaluation',
'permission_page' => 'index'
),
array(
'role_id' => '3',
'role_name' => 'team leader',
'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market',
'role_department_id' => '2',
'department_id' => '2',
'department_name' => 'brand centrical',
'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.',
'user_role_permission_id' => '9',
'user_permission_id' => '25',
'permission' => 'leave',
'permission_page' => 'newrequest'
),
array(
'role_id' => '3',
'role_name' => 'team leader',
'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market',
'role_department_id' => '2',
'department_id' => '2',
'department_name' => 'brand centrical',
'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.',
'user_role_permission_id' => '10',
'user_permission_id' => '26',
'permission' => 'leave',
'permission_page' => 'create'
),
array(
'role_id' => '3',
'role_name' => 'team leader',
'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market',
'role_department_id' => '2',
'department_id' => '2',
'department_name' => 'brand centrical',
'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.',
'user_role_permission_id' => '17',
'user_permission_id' => '27',
'permission' => 'leave',
'permission_page' => 'viewall'
),
array(
'role_id' => '3',
'role_name' => 'team leader',
'role_description' => 'Competently brand orthogonal e-tailers vis-a-vis just in time manufactured products. Interactively extend performance based relationships for ubiquitous total linkage. Collaboratively fabricate stand-alone customer service whereas flexible growth strategies. Assertively harness fully tested e-market',
'role_department_id' => '2',
'department_id' => '2',
'department_name' => 'brand centrical',
'department_description' => 'Distinctively implement turnkey action items without distributed e-business. Globally visualize reliable core competencies via optimal imperatives. Seamlessly revolutionize standards compliant partnerships rather than functionalized convergence. Intrinsicly expedite intuitive functionalities after frictionless e-services. Seamlessly impact user-centric core competencies for resource sucking processes.',
'user_role_permission_id' => '11',
'user_permission_id' => '28',
'permission' => 'leave',
'permission_page' => 'response'
)
);
解
$new = array();
foreach($array as $r) $new[$r['permission']][] = $r['permission_page'];
echo '<pre>';print_r($new);
?>
輸出值
Array
(
[employee] => Array
(
[0] => newemployee
[1] => edit
[2] => update
)
[suggestion] => Array
(
[0] => view
)
[evaluation] => Array
(
[0] => index
)
[leave] => Array
(
[0] => newrequest
[1] => create
[2] => viewall
[3] => response
)
)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.