Laurensius Tony Laurensius Tony - 18 days ago 8
PHP Question

take first level of multidimensional array

so i am using laravel kodeine package for access control list and i got a problem with retrieving permission from the role.. it just have a different data form, from what i expected from laravel packages...

it come with array like this

array:4 [▼
"artikel_view" => array:1 [▼
"view" => true
]
"artikel_create" => array:1 [▼
"create" => true
]
"artikel_update" => array:1 [▼
"update" => true
]
"artikel_destroy" => array:1 [▼
"destroy" => true
]
]


so what i need is taking the first level like artikel_view, artikel_create, artikel_update, artikel_destroy

how to do that? i tried to do normal foreach loop but getting only the second level of array like view, create, update, destroy

Answer
$permissions = array(
  "artikel_view" => array(
    "view" => true
  ),
  "artikel_create" => array(
    "create" => true
  ),
  "artikel_update" => array(
    "update" => true
  ),
  "artikel_destroy" => array(
    "destroy" => true
  )
);

$perms = array_keys($permissions);

var_dump($perms);