• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 267
  • Last Modified:

PHP foreach List


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.

$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 } ?>

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.
1 Solution
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
echo ..
JiveMediaAuthor Commented:
Perfect, thanks for the help!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

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