<?php

$swallowed = array(
  array('swallowed' => 'fly.',
        'reason' => ),
  array('swallowed' => 'spider,',
        'aside' => ,
        'reason' => ),
  array('swallowed' => 'bird.',
        'aside' => ,
        'reason' => ),
  array('swallowed' => 'cat.',
        'aside' => ,
        'reason' => ),
  array('swallowed' => 'dog.',
        'aside' => ,
        'reason' => ),
  array('swallowed' => 'horse',
        'aside' => ,
        'reason' => ));

foreach($swallowed as $creature)
{
  print  . $creature['swallowed'] . ;
  if(array_key_exists('aside', $creature))
    print $creature['aside'] . ;

  $reversed = array_reverse($swallowed);
  $history = array_slice($reversed, array_search($creature, $reversed));

  foreach($history as $note)
  {
    print $note['reason'] . ;
  }

  if($swallowed[count($swallowed) - 1] == $creature)
    print ;
  else
    print  . ;
}