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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.