CSci 1101 Lab 7. Thursday, April 9.

Work in groups of two.

Recursive printing of a nested array

The task is to print out an array that has subarrays of an arbitrary nesting. Each next level of nesting should be indented relative to the previous one (similar to threads of comments). This is very similar to what you need to do for the project, except for the database access.

You might want to use <div> and CSS margin property for thsi task, but other approaches are fine as well.

Note: this lab is graded based on participation only, do not put more than 40 minutes into this lab. Send me a link to your solution. If it doesn't work, write (in comments or in the e-mail message) what your next would have been.

Here is the starting code:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Recursive array printing
Author: Elena Machkasova 
Last modified: 4/9/09
<html xmlns="" xml:lang="en" lang="en">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
CSci 1101: Recursive array printing
// the function is given an array that may 
// contain nested subarrays. The function
// prints the array elements indenting each level
function print_nested_array($array) {
$strings = array("Level one", array("Level two", "Another level two"), 
array("Level two, second thread", array("Level three", "More level three")), 
"Back to level one again");
print "<pre>";
print "</pre>";

To submit

Just save the file(s) on csci1101sp09 or, if using remote access, upload them to csci1101sp09. Send me an e-mail with the URL of the files when done, do not move the files after the submission. Make sure to CC your group partner.

This page is a part of CSci 1101 course web site.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.