2010-10-22 2 views
1

У меня есть многомерный массив созданный в PHP:перекручивание через многомерный массив в Smarty

array(
      'Requirements' => array(
       'export_requirements' => array('value'=> 1, 'label'=> 'Export'), 
       'add_requirements' => array('value'=> 2, 'label'=> 'Add'), 
       'add_private_requirements' => array('value'=> 4, 'label'=> 'Add Private Requirements'), 
       'log_activity' => array('value'=> 8, 'label'=> 'Log Activity/Schedule Event'), 
       'edit_activity' => array('value'=> 16, 'label'=> 'Edit Activity'), 
       'delete_activity' => array('value'=> 32, 'label'=> 'Delete Activity'), 
       'edit_requirements' => array('value'=> 64, 'label'=> 'Edit Requirements'), 
       'edit_requirements_private' => array('value'=> 128, 'label'=> 'Edit Private Requirements'), 
      ), 
      'Resources' => array(
       'export_resources' => array('value'=> 1, 'label'=> 'Export'), 
       'add_resources' => array('value'=> 2, 'label'=> 'Add'), 
       'add_private_resources' => array('value'=> 4, 'label'=> 'Add Private Resources'), 
       'log_activity' => array('value'=> 8, 'label'=> 'Log Activity/Schedule Event'), 
       'edit_activity' => array('value'=> 16, 'label'=> 'Edit Activity'), 
       'delete_activity' => array('value'=> 32, 'label'=> 'Delete Activity'), 
       'edit_resources' => array('value'=> 64, 'label'=> 'Edit Resources'), 
       'edit_resources_private' => array('value'=> 128, 'label'=> 'Edit Private Resources'), 
      ), 
      'Prospects' => array(
       'export_prospects' => array('value'=> 1, 'label'=> 'Export'), 
       'add_prospects' => array('value'=> 2, 'label'=> 'Add'), 
       'show_nsa' => array('value'=> 4, 'label'=> 'Show NSA Details'), 
       'edit_prospects' => array('value'=> 8, 'label'=> 'Edit'), 
       'log_activity' => array('value'=> 16, 'label'=> 'Log Activity/Schedule Event'), 
       'edit_activity' => array('value'=> 32, 'label'=> 'Edit Activity'), 
       'delete_activity' => array('value'=> 64, 'label'=> 'Delete Activity'), 
      ), 
      'Contacts' => array(
       'export_contacts' => array('value'=> 1, 'label'=> 'Export'), 
       'add_contacts' => array('value'=> 2, 'label'=> 'Add'), 
       'edit_contacts' => array('value'=> 4, 'label'=> 'Edit'), 
       'log_activity' => array('value'=> 8, 'label'=> 'Log Activity/Schedule Event'), 
       'edit_activity' => array('value'=> 16, 'label'=> 'Edit Activity'), 
       'delete_activity' => array('value'=> 32, 'label'=> 'Delete Activity'), 
      ), 
      'Clients' => array(
       'export_clients' => array('value'=> 1, 'label'=> 'Export'), 
       'add_clients' => array('value'=> 2, 'label'=> 'Add'), 
       'show_caution_note' => array('value'=> 4, 'label'=> 'Show Caution Note'), 
       'show_nsa_msa' => array('value'=> 8, 'label'=> 'Show NSA and MSA Details'), 
       'edit_dormant_caution_caution_notes' => array('value'=> 16, 'label'=> 'Edit Dormant, Caution, Caution Notes'), 
       'log_activity' => array('value'=> 32, 'label'=> 'Log Activity'), 
       'edit_activity' => array('value'=> 64, 'label'=> 'Edit Activity'), 
       'delete_activity' => array('value'=> 128, 'label'=> 'Delete Activity'), 
      ), 
      'Reports' => array(
       'view' => array('value'=> 1, 'label'=> 'View'), 
      ), 
      'Settings' => array(
       'administration' => array('value'=> 1, 'label'=> 'Administration'), 
       'view_data_item_history' => array('value'=> 2, 'label'=> 'View Data Item History'), 
       'assign_group_permissions' => array('value'=> 4, 'label'=> 'Assign Group Permissions'), 
       'manage_users' => array('value'=> 8, 'label'=> 'Manage Users'), 
       'assign_user_permissions' => array('value'=> 16, 'label'=> 'Assign User Permission'), 
       'manage_roles' => array('value'=> 32, 'label'=> 'Manage Roles'), 
       'assign_role_permission' => array('value'=> 64, 'label'=> 'Assign Role Permission'), 
      ), 
     ); 

Есть ли способ Переберите это с помощью Smarty?

я получил до сих пор:

{foreach from=$all_perms key=k item=v} 
      <table width="100%" border="0" cellspacing="0" cellpadding="0" class="detail view"> 
       <tr> 
       <th colspan='4' align="left" width="100%" valign="top"><h4><slot>{$k}</slot></h4></th> 
       </tr> 
       {foreach from=$all_perms key=k item=v} {% I'm stuck at this for loop %} 
        <tr> 
         <td width="15%" valign="top" scope="row"> 
          <slot>{$k}:</slot> 
         </td> 
         <td width="85%" valign="top"> 
          <slot>Allow</slot> 
         </td> 
        </tr> 
       {/foreach} 
      </table> 
     {/foreach} 

ответ

2

Попробуйте изменить второй цикл:

{foreach from=$v key=key item=value} 
Смежные вопросы