There are two things you need to do to troubleshoot this problem. INSIDE your function, at the very top, do this:
First, echo out one of the arrays like this:
[PHP]
echo "";
print_r($Date_Added);
echo "";
[/PHP]
Then echo out the value of $num:
[PHP]
echo "".$num;
[/PHP]
You should see that $num = 0, but that your array does not even exist. You forgot one important line at the top of your function:
[PHP]
global $Date_Added, $Sample_Views;
[/PHP]