"Review 2 other people's code and provide a 1/2 page written report on how their solution differs from yours." I reviewed the first two classmates with posted websites: Cooley and Lapsley. For clarity, I reviewed the three solutions problem by problem.
Problem 1: . . . uses 10 different variables to store data: text/numbers. Print . . . modify each variable, without reinitializing, and display
Cooley used all STRING data for the 10 variables while Lapsley used 1 INTEGER and remaining variables were STRING. I wanted to experiment with all PHP seven data types: NULL, STRING, INTEGER, DOUBLE “REAL” BOOLEAN, OBJECT, and ARRAY; therefore, I used all seven types and changed their values and data types using SETTYPE and assignment operators. Both Cooley and Lapsley used reassignment to change the values of their variables. Lapsley also used STRING manipulation to change variable values. Lapsley used HTML TABLE formatting to display variables, Cooley used an array to print STRING values as a complete sentence. I used both HTML TABLE formatting.
Problem 2: . . . WHILE . . . FOR loop . . . display depending on the value of each array element
Like Cooley, I used separate FOR loop and WHILE loop to print a STRING data from an ARRAY to produce a sentence. Unlike Cooley, I used a IF conditional printing in the second loop to change the output. Lapsley begins his code with a a function to test for even and odd numbers foreshadowing future assignment. Using INTEGER data, the function tests for even/odd and then prints the background cell color and value position based on results. Cooley and Lapsley both used straightforward FOR and WHILE loops to iterate through and ARRAY without conditional formatting.
Problem 3: . . . phone book program . . . use an associative array
The major difference between Cooley and Lapsley code is I used "$variable names" to maintain future flexibility permitting the processing loop to read an ARRAY of an unknown number of records from a file or keyed input. Lapsley used function call for PHP conditional formatting of the display whereas Cooley and I both relied ECHO/PRINT of HTML formatting commands to a TABLE output. Both Cooley and Lapsley processed one-dimensional ARRAY while I used a multi-dimensional foreshadowing how PHP handles database management tasks. Lapsley again relied on complex formatting with FUNCTIONS and a minimal amount of HTML commands to produce random list and a sorted list. Cooley also used KSORT function to sort the phone book lists.
Problem 4: program that sums and multiplies all the odd numbers from 1 to 1000, inclusive. . . . use only ONE loop. Display
Both Cooley and I used a FOR loop and incremented the counter value by two for each iteration. Lapsley coded the solution with a more complicated function that tested for an odd number within in the processing loop. He used the HTML attribute "align=center" to create a nice display of the multiplied products. I noticed both Cooley and Lapsley"hard coded" values where I tried to use initialized VARIABLES to increase the ease of future program modifications. At this point, I started reserving the command, ECHO, for debug printing and STRING values only printing. I found this as method for easier syntax debugging. I also prefer COMMENTS on a separate line rather than annotating command lines to ease the task of syntax and logic debugging. Both Cooley and Lapsley used end-of-command line annotations which I found a little distracting in following the logic of their coding.
Problem 5: program that manipulates an array using the various array functions. . . . Use push, pop, shift and count.
Cooley used a single variable to create a data set and then used STRING manipulation to PUSH the separate items into an ARRAY. Lapsley created a one-dimensional ARRAY for the data set. Cooley used a new function for me, PRINT_LIST, to display the manipulated ARRAY contents. We all used a temporary ARRAY to store removed items using SHIFT and POP. Cooley displayed the results of ARRAY manipulation as a series of sentences. Lapsley used TABLES. I used the displayed output to explain the the process and the results. I used conditional IF to selectively PUSH data into the new ARRAY. I also used simple error checking such as verifying the newly created ARRAY is an effect an ARRAY with GETTYPE before beginning the processing of data.