php - How not to repeat array in a function to use foreach -


this works fine, it's goofy me don't know search (or if question titled correctly) learn how accomplish not repeating $slide_panels array within christina_slide_in_panels() function below , outside it.

sadly, question closed answer steve in comments. question not answered reading "duplicate" post accepted answer, @ least not specifically.

//* register slide panels  $slide_panels = array (             'slide-1'       => 'slide panel one',             'slide-2'       => 'slide panel two',             'slide-3'       => 'slide panel three',             'slide-4'       => 'slide panel four',             );   foreach ( $slide_panels $id => $slide_panel) {     register_sidebar(         array (                 'name'          => __( $slide_panel, 'christina' ),                 'id'            => $id,                 'before_widget' => '<aside id="%1$s" class="slide-widget %2$s">',                 'after_widget'  => '</aside>',                 'before_title'  => '<h3 class="slide-widget-title">',                 'after_title'   => '</h3>',         ));  }   //* create panels  function christina_slide_in_panels() {     //======== > how not repeat < ========    $slide_panels = array (             'slide-1'       => 'slide panel one',             'slide-2'       => 'slide panel two',             'slide-3'       => 'slide panel three',             'slide-4'       => 'slide panel four',             );        echo '<!-- begin slide panels --><div class="slide-in-panels-parent">';      foreach ( $slide_panels $id => $slide_panel) {          if ( is_active_sidebar( $id ) ) {              echo '<div class="slide-panel" id="'.$id.'" aria-expanded="false" aria-hidden="true">';             // id used on toggle slide in              dynamic_sidebar( $id );              echo '</div><!-- close '.$id.' -->';         }         //end endif;     }     //end foreach      echo '</div><!-- end slide panels -->';     //close parent;   } add_action('genesis_after', 'christina_slide_in_panels'); 


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -