Title: Sharing a conditional statement
Last modified: August 31, 2016

---

# Sharing a conditional statement

 *  Resolved [crlannen](https://wordpress.org/support/users/crlannen/)
 * (@crlannen)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sharing-a-conditional-statement/)
 * In my custom template I needed to have a hyphen (-) as a separator between the
   degree/certification and the granting institution. On rhw doem rhwew EW 5 degree/
   granting institutions, and if the degree field is blank I didn’t want a hyphen
   appearing with no information in the PDF.
 *     ```
       {Degree/Certification:7}<?php
       $separator = $form_data['field'][7];
       // only print out hyphen if the certification field is completed
         if ($separator != "")
         {
         echo " - ";
       } ?> {Educational Institution/Professional Organization:8}
       ```
   
 * The above is repeated for each of the additional degrees, but with the Degree/
   Certification field number changed.
 * I hope this helps someone.
 * [https://wordpress.org/plugins/gravity-forms-pdf-extended/](https://wordpress.org/plugins/gravity-forms-pdf-extended/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Jake Jackson](https://wordpress.org/support/users/blue-liquid-designs/)
 * (@blue-liquid-designs)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/sharing-a-conditional-statement/#post-7197235)
 * Hi,
 * When working with repetitive data like you mentioned we find it’s best to make
   an array with your field IDs and loop through it:
 *     ```
       <?php 
   
       $certificates = array(
           array(
               'degree'    => $form_data['field'][7],
               'education' => $form_data['field'][8],
           ),
   
           array(
               'degree'    => $form_data['field'][10],
               'education' => $form_data['field'][12],
           ),
   
           array(
               'degree'    => $form_data['field'][16],
               'education' => $form_data['field'][20],
           ),
       );
   
       foreach ( $certificates as $item ) {
           if( strlen( $item['degree'] ) > 0 && strlen( $item['education'] ) > 0 ) {
               echo $item['degree'] . ' – ' . $item['education'] .'<br>';
           }
       }
       ```
   
 * Change the field IDs as needed and modify the conditional to suit.

Viewing 1 replies (of 1 total)

The topic ‘Sharing a conditional statement’ is closed to new replies.

 * ![](https://ps.w.org/gravity-forms-pdf-extended/assets/icon-256x256.png?rev=3168987)
 * [Gravity PDF](https://wordpress.org/plugins/gravity-forms-pdf-extended/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/gravity-forms-pdf-extended/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/)
 * [Active Topics](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/gravity-forms-pdf-extended/reviews/)

## Tags

 * [conditional statement](https://wordpress.org/support/topic-tag/conditional-statement/)
 * [Custom PDF](https://wordpress.org/support/topic-tag/custom-pdf/)

 * 1 reply
 * 2 participants
 * Last reply from: [Jake Jackson](https://wordpress.org/support/users/blue-liquid-designs/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/sharing-a-conditional-statement/#post-7197235)
 * Status: resolved