$theData
Here is the content of the data file, represented in the array \$theData_byrow. Notice that each element of the array contains a string that represents the ENTIRE ROW of data for a person. Within each folder in the array, we have the information we need (separated by commas), but it is all represented as a single string. We'll need to explode the data one more time (within persons) to extract the comma-delimited information.
"; print_r($theData_byrow); print "Let's try to break this down within a person by using a foreach loop to sort through each element of the array. We will print the 3rd element for each person. (Don't forget that PHP starts counting at 0.) This value in the dataset represents the person's rating of the photo on a 1 to 5 scale.
"; foreach($theData_byrow as $key => $value){ $theData_thisPerson = explode(",",$value); print "The 3rd value for row $key is $theData_thisPerson[3].The average rating for people is $sample_mean.
"; /* Some things to note: - This particular process can be made more efficient by creating a function to average things. Otherwise, we would have to do something like this fresh everytime we wish to average a variable. We'll discuss functions separately. - This particular code does not handle missing data well. We can do more sophisticated things to deal with missing data. But I don't want to overcomplicate things at this point. - Notice that we started with a predefined value for $n and $sum. This wasn't technically necessary. But, in some applications, it can be handy to start with n being slightly > 0 so you don't accidentally divide by 0 and anger the gods. */ ?>