Jump to content

[SOLVED] Associative Array Problem w/ Multiple Values


kjtocool

Recommended Posts

I am writing a function which takes two arrays filled with movie name > movie gross pairs.  The arrays are in no order, and the function will return a score for each movie, comparing the correct values in each array. 

 

I am not having a problem with the function, it works fine.  But the line with comments above it is throwing an error when I try and add a new value to the array.

<?php
function get_user_scores($user_array, $actuals_array) {
$array = array();
foreach ($user_array as $user_name => $user_gross) {
	foreach ($actuals_array as $actual_name => $actual_gross) {
		if ($user_name == $actual_name) {
			$difference = $user_gross - $actual_gross;
			$absolute = abs($difference);
			$score_unformated = $absolute / $actual_gross;
			$score = 1 - $score_unformated;
			$score = $score * 100;
			$score = round($score, 3);
			if ($score < 0) {
				$score = 0;
			}
                                // This line (below) is throwing an error.
			$array[$user_name] = $score, $actual_gross;
		}
	}
}
return $array;
}
?>

 

Error:

Parse error: syntax error, unexpected ',' in /home/worldofk/public_html/bonanza_results.php on line 269

 

Shouldn't this be a legal addition to an associative array?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.