• Resolved research12345

    (@research12345)


    How do you display the contents of an array inside foreach? echo only displays values if the field is not linked to another table. In this case, “Author” is an array. I can display the “Title”, which uses “Link” as the link, but “Author” just returns the text, “Array.” Any help would be so appreciated – php newbie here!

    <?php
    $query = new AirpressQuery();
    $query->setConfig("Academic");
    $query->table("Feeds")->view("Grid");
    $query->addFilter("{Source}='Film Journals'");
    
    $events = new AirpressCollection($query);
    ?>
    
    <div>
    <ul>
    <?php 
    foreach ($events as $pubitems) {
      echo '<li>' . '<a href=' . $pubitems["Link"] . '</a>' . $pubitems["Title"] . '</a>' . ": " . $pubitems["Author"] . '</li>';
    }
    ?>
    </ul>
    </div>
Viewing 1 replies (of 1 total)
  • Plugin Author Chester McLaughlin

    (@chetmac)

    Perhaps this snippet will help:

    
    <?php
    
    $query = new AirpressQuery();
    $query->setConfig("Academic");
    $query->table("Feeds")->view("Grid");
    $query->addFilter("{Source}='Film Journals'");
    
    $events = new AirpressCollection($query);
    
    $field = "Author";
    $table = "Authors";
    
    $events->populateRelatedField($field,$table);
    
    ?>
    
    <div>
    	<ul>
    	<?php 
    	foreach ($events as $pubitems) {
      		echo '<li>' . '<a href=' . $pubitems["Link"] . '</a>' . $pubitems["Title"] . '</a>' . ": " . $pubitems["Author"][0]["Name"] . '</li>';
    	}
    	?>
    	</ul>
    </div>
    
Viewing 1 replies (of 1 total)
  • The topic ‘Display content of array in looped foreach’ is closed to new replies.