6.863 Course Discussion Board
<return to top>
'$matches[0]' '$line'"; $idx = explode(".",trim($matches[0])); // create & index through the tree $aryref = &$discussion_tree; foreach ($idx as $key) { if (!($key)) { $key = 0; } // var_dump($aryref); // its ok to create each as an array. strings will overwrite. if (! $aryref[$key]) { $aryref[$key] = array(); } $aryref = &$aryref[$key]; // echo "[$key] [$aryref]"; // [0][0] // [1][0] } $aryref = stripslashes($line); // echo "[$key] [$aryref]"; } // not a new entry, add to existing array elseif($aryref) { $aryref .= "\n" . stripslashes($line); } } echo "
"; ?>
= 0; $i--) //each ($branch as $branchkey => $branchval) { array_push($branchstack, $branch[$i]); // echo "
$branchkey $branchval\n"; } } else { $matches = array(); preg_match('/^(\d+\.\d*)+\s/',$branch, $matches); $branch = preg_replace('/^(\d+\.\d*)+\s/','', $branch); // check alignment $size_old = count(explode(".",$lastid)); $size_new = count(explode(".",$matches[0])); // correct for start of list // if (! $lastid) { $size_old = $size_new; } if ($size_new > $size_old) { $tag = "
    \n"; $start = $size_old; $end = $size_new; } elseif ($size_new < $size_old) { $tag = "
\n"; $start = $size_new; $end = $size_old; } else { $tag = ""; $start = 0; $end = 0; } // echo "[$start $end $tag]"; for ($j=$start; $j < $end; $j++) { echo $tag; } // only time to insert a linebreak is when we are at the same "level" if ($start == $end) { echo "
"; } // hand 'root' styles and sizes. (should only have 2 fields) if ($size_new == 2) { echo "
$branch\n
<post new thread>\n"; } else { echo "
  • " . substr($branch,0,50) . "...
  • \n"; } $lastid = $matches[0]; } } ?>
     

     
    Message:

    Email:  (optional)