I'm trying to do a filter function in PHP. I have started doing the bellow:
function handleDuplicates($duplicateMonthReportsArray,$NodeReports,$whatToCompare){
foreach ($duplicateMonthReportsArray as $duplicate) {
$duplicateReportsArray = $NodeReports->nodeReports[$duplicate]->indvReports;
var_dump($duplicateReportsArray); //Prints out what I have written bellow
foreach ($duplicateReportsArray as $duplicateReport) {
if($whatToCompare==="both"){
//Return higest [NoSamples] and latest ["StopTime"] (If possible).
}
else if($whatToCompare==="latest"){
//Return array with latest ["StopTime"]
}else{
//Return array with higest [NoSamples] (If both same like the bellow case then return latest "StopTime")
}
}
}
}
And the var_dump prints out the bellow:
array(2) {
[""AU Feb-13",201302282 "]=>
array(2) {
["StopTime"]=>
string(23) "2013-02-28 23:00:00.000"
["NoSamples"]=>
string(5) "673.0"
}
[""AU Feb-13",201302282 "]=>
array(2) {
["StopTime"]=>
string(23) "2013-02-28 23:55:00.000"
["NoSamples"]=>
string(5) "673.0"
}
}
What I want to do is printed in the code as comments. I want to do a customized filter function that loops through an array of objects that looks like the var_dump that I have written above and either return the array instance with higest "StopTime", "higest NoSamples" or both (If possible, otherwise return only the largest "NoSamples".
How would you go about implementing this filterfunction? Are there any finished filter functions ready to be used in my case, that takes an array of arrays and perform a filter on that?
Thanks alot in advance.