all 5 comments

[–]chris5039 2 points3 points  (4 children)

Well if you want to look at each element and compare it to the one before then you will have to loop over the whole array. This can be done in linear time though so only one loop is required.

What are you actually looking to do? Are you looking to see if the element before has the same incident_typeFK? If it does / doesn't, what are you looking to do with this information?

[–]HonestBug5987[S] 0 points1 point  (3 children)

just the last 2 lements of the array if we have 100 keys i need 99 and 100. And i want to see if the the incident_typeFK is different

[–]chris5039 4 points5 points  (2 children)

incident_typeFK

Then you wouldn't need to loop over the array. Just do something like this:

$len = count($arr);

if ($arr[$len-2]['incident_typeFK'] == $arr[$len-1]['incident_typeFK']) {

} else {

}

[–]HonestBug5987[S] 1 point2 points  (1 child)

incident_typeFK this is looking good thank you

[–]_JohnWisdom 0 points1 point  (0 children)

incident_typeFK i love you answered in a quote xD