Working with ‘join’ code

3 posts by 2 authors in: Forums > CMS Builder
Last Post: April 13, 2016   (RSS)

By Damon - April 13, 2016

Hi Jerry,

Here is one way to do it:

<table class="text_font" width="100%" border="1"  cellspacing="0">
          <tr>
            <td style="padding-left:10px;">Last Name</td>
            <td style="padding-left:10px;">First Name</td>
            <td style="padding-left:10px;" colspan="3">Assignments</td>
          </tr>
    <?php foreach ($accountsRecords as $record ): ?>
       <?php if(substr_count($record['allowedFolders'], "\t") > 2): ?>
          <tr>
            <td style="padding-left:10px;"><?php echo $record['last_name'] ?></td>
            <td style="padding-left:10px;"><?php echo $record['first_name'] ?></td>
            <td style="padding-left:10px;"><?php echo join(', ', $record['allowedFolders:labels']);?></td>
         </tr>
       <?php endif?>
    <?php endforeach; ?>
</table>


Counting the tab spaces in the allowedFolders string. One value equals two tab spaces so I added the more than 2 condition.

Try this out and let me know if this gives you the results you are after.

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By gkornbluth - April 13, 2016 - edited: April 13, 2016

A perfect and elegant solution, and definitely a new recipe for the cookbook.

Thank you again, Damon,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php