Meta Box
Support › General › Add a separator to fileResolved
Hi, I have that code
<?php $files = rwmb_meta( 'planimetrie' ); foreach ( $files as $file ) { ?> <a>" target="_blank"><?php echo $file['name']; ?></a> <?php } ?>
that retrieve a file list and open it in a new blank page, but i'm not sure where place the separator to have: file1, file2...
Anyone can help? thanks
Hi,
You can just add the separator after the closing tag </a>
</a>
<a href="<?php echo $file['url']; ?>" target="_blank"><?php echo $file['name']; ?></a>,
It's working, but that add the ',' after the last file. How I can add a separator only to the other list file?
You can count the number of files then check in the loop if reach the last file and remove the separator. Just like
$files = rwmb_meta( 'planimetrie' ); $count = count( $files ); $i = 1; foreach ( $files as $file ) { if( $i < $count ) { ?> <a href="<?php echo $file['url']; ?>" target="_blank"><?php echo $file['name']; ?></a>, <?php } else { ?> <a href="<?php echo $file['url']; ?>" target="_blank"><?php echo $file['name']; ?></a> <?php } $i++; }