1

This my array which contains employee role details, department details and permission details.

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
        )

)

In the above code block you can see [permission] => employee is same for [0],[1],[2] arrays too. But [permission_page] is different. So, I want a multidimensional array like shown below. Here, [permission] array contains all the [permission_page]. I want to implement my code in a similar fashion as shown below. Any help would be much appreciated.

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
        )

)
1
  • 1
    You should post the code that you tried but was not working . Then we can do anything for you. Commented Jan 3, 2018 at 6:19

4 Answers 4

3

Get all values of permission and permission page, then loop on permission to get grouping permission wise pages.

$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 — Return the values from a single column in the input array

Here is working demo.

Sign up to request clarification or add additional context in comments.

Comments

1

Here is your solution

INPUT

<?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'
        )
    );

Solution

    $new = array();
    foreach($array as $r) $new[$r['permission']][] = $r['permission_page'];
    echo '<pre>';print_r($new);

?>

OUTPUT

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
        )

)

Comments

1

Use foreach then push each permission_page to $result with permission as key

$result = [];
foreach ($array as $object) {
    $result[$object->permission][] = $object->permission_page;
}

echo '<pre>';
print_r($result);

Comments

1

I created below code. Hope It can help you. It gives exact output as u want.

<?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;	
?>

3 Comments

I got exact output as mentioned above. So it is not wrong. That is correct the way I answered is different but not wrong. FYI. If it is wrong then u can create one file index.php and paste my code and run . If u didnt get same output as above then u can say my answer is wrong. Thanks
This is the output I'm getting by your code... Output
Yes my mistake. I corrected. I didn't define variable here. $var = $d['permission'] Thanks for correcting me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.