comparing numeric array values side by side

Soldato
Joined
7 Jan 2007
Posts
10,607
Location
Sussex, UK
Hope people can help me, I am trying to build some validation into my script that updates statistics each week.

I have an array that has $ThisWeeksStats in it and I want to ensure it is not equal to $LastWeeksStats and to ensure that $ThisWeeksStats is numeric

I realise that statistically it is possible to have the same stats but it is highly unlikely to happen :D

I currently have:

PHP:
if ($ThisWeeksStats != $LastWeeksStats && is_numeric($ThisWeeksStats)) {
    print '$ThisWeeksStats';
}
else {
    print 'either the numbers are equal to each other or there isnt numerics in this weeks results';
}

$ThisWeeksStats consists of:
Code:
key: 0 , value: 976 
key: 1 , value: 830 
key: 2 , value: 444 
key: 3 , value: 898 
key: 4 , value: 2325
key: 5 , value: 1599

$LastWeeksStats consists of:
Code:
key: 0 , value: 5103
key: 1 , value: 1367 
key: 2 , value: 790 
key: 3 , value: 665 
key: 4 , value: 88 
key: 5 , value: 5432

The if statement doesn't seem to work so I am assuming it isn't comparing the arrays properly?
 
Why not put it in an object with a timestamp then you'll know what week it's for?

being different from the previous week is a weak way of determining if the stats are new.

Yeh I see what you're saying but there is no guarantee that someone has updated the new stats in the remote xml so i need to check the numbers are not the same between the two arrays.


hhhmmm but how would I validate if the numbers are different if I only used timestamps? If I am following I could end up with duplicate data if I only looked at the timestamp? Thats if nobody updates the remote xml when my script is run.

I'm scraping stats off a remote xml.
 
Last edited:
Back
Top Bottom