<?php

class articleClass {
	
  private $author;
  private $title;

  function __construct($author, $title) {
  	$this->author = $author;
  	$this->title = $title;
  }

  function author() {
  	return $this->author;
  }
  
  function title() {
  	return $this->title;
  }
}

class pageClass {

  private $name;
  private $author;	
  private $articles;

  function __construct($name, $author, array $articles) {
  	$this->name = $name;
  	$this->author = $author;
  	$this->articles = $articles;
  }
  
  function author() {
  	return $this->author;
  }

  function children() {
  	return $this->articles;
  }
}

function page($name) {
	
	if ($name == 'magazine') {
		
		$articles = array(
		  new articleClass('John', 'Technology News'),
		  new articleClass('Joe', 'Industry News'),
		  new articleClass('Joe', 'More Industry News'),
		  new articleClass('Jane', 'Fashion News'),
		);
	
	    return new pageClass('magazine', 'Joe', $articles);
	    
	} else {
		
		throw new Exception('Page not found');
		
	}
	
}



?>
<div id="automatic_list_of_articles">

    <?php $page = page('magazine'); ?>

    <?php foreach($page->children() as $article): ?>

        <?php if($article->author() == $page->author()): ?>
            <p><?php echo $article->title() ?></p>
        <?php endif ?>

    <?php endforeach ?>

</div>