Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

PHP foreach List

Hi,

Looking for some help with my PHP foreach loop below.

I currently have the below working on my website which displays a list of information (title and some text information next to it for each row) in my concrete5 site.

<?php
$attr_set = AttributeSet::getByHandle('projects');
$attr_keys = $attr_set->getAttributeKeys();
?>
<ul id="projectList" class="list-alignLeft">
<?php foreach($attr_keys as $ak) { ?>
<li class="projectLabel"><?= $ak->akName ?></li>
<li class="projectInfo"><?= $c->getAttribute($ak->akHandle) ?></li>
<?php } ?>
</ul>

Open in new window


I would like to test the $ak->akHandle variable to see if its empty then omit that row (and the title next to it) from the list of data if empty.

I would also like to see if the last variable in the array (project_link) has data then make it a link if so.

Could someone please help with the above.

Many thanks.
0
JiveMedia
Asked:
JiveMedia
1 Solution
 
aboo_sCommented:
foreach($attr_keys as $ak)
this already deals with rows that exist (not empty) unless you mean some other thing when you say empty.
anyway you can do this
if(strlen($c->getAttribute($ak->akHandle))>0)
{
echo ..
}
0
 
JiveMediaAuthor Commented:
Perfect, thanks for the help!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now