Hope this is what you expect.
Happy coding .. :)
<?php
$permissions = ['create_user', 'create_post','edit_post', 'delete_post', 'edit_user', 'delete_user'];
$permission_categories = [];
$set = [];
foreach ($permissions as $permission) {
$name = explode("_", $permission);
$key = $name[1];
$value = $name[0];
if (!array_key_exists($key, $permission_categories)) {
$permission_categories[$key] = [$value];
}else{
array_push($permission_categories[$key],$value);
}
}
print_r($permission_categories);
exit();