<?php
function returnJson( $jsonArray ) {
$totalScore1 = [ ] ;
$totalScore2 = [ ] ;
$totalScore3 = [ ] ;
$totalScore4 = [ ] ;
$totalScore5 = [ ] ;
foreach ( $jsonArray as $value ) {
if ( $value [ "type" ] == "yyy" ) {
$number = $value [ "user" ] ;
$score = $value [ 'score' ] ;
switch ( $number ) {
case 0 :
array_push ( $totalScore1 , [ "_id" => $value [ "_id" ] , "score" => $score , "user" => $number , "type" => $value [ "type" ] ] ) ;
break ;
case 1 :
break ;
case 2 :
break ;
case 3 :
break ;
case 4 :
break ;
}
}
}
$result = checkArray( $totalScore1 ) ;
//var_dump($totalScore1[1]);
}
function checkArray( $totalScore ) {
for ( $i = 0 ; $i <= count ( $totalScore ) ; $i ++ ) {
}
}
if ( count ( $totalScoreUnique ) > 1 ) {
$min = min ( $totalScoreUnique ) ; return $totalScoreUnique ;
}
return $totalScoreUnique ;
}
returnJson( $jsonArray ) ;
PD9waHAKCgokanNvbkFycmF5ID0ganNvbl9kZWNvZGUoJGpzb24sIHRydWUpOwoKZnVuY3Rpb24gcmV0dXJuSnNvbigkanNvbkFycmF5KSB7CiAgICAkdG90YWxTY29yZTEgPSBbXTsKICAgICR0b3RhbFNjb3JlMiA9IFtdOwogICAgJHRvdGFsU2NvcmUzID0gW107CiAgICAkdG90YWxTY29yZTQgPSBbXTsKICAgICR0b3RhbFNjb3JlNSA9IFtdOwoKICAgIGZvcmVhY2ggKCRqc29uQXJyYXkgYXMgJHZhbHVlKXsKICAgICAgICAKICAgICAgICBpZiAoJHZhbHVlWyJ0eXBlIl0gPT0gInl5eSIpIHsgCiAgICAgICAgICAgICRudW1iZXIgPSAkdmFsdWVbInVzZXIiXTsKICAgICAgICAgICAgJHNjb3JlID0gJHZhbHVlWydzY29yZSddOwogICAgICAgICAgICAKICAgICAgICBzd2l0Y2goJG51bWJlcil7CiAgICAgICAgICAgIGNhc2UgMDoKICAgICAgICAgICAgYXJyYXlfcHVzaCgkdG90YWxTY29yZTEsIFsiX2lkIiA9PiAkdmFsdWVbIl9pZCJdLCAic2NvcmUiID0+ICRzY29yZSwgInVzZXIiID0+ICRudW1iZXIsICJ0eXBlIiA9PiAkdmFsdWVbInR5cGUiXV0pOwogICAgICAgICAgICAKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIGNhc2UgMToKICAgICAgICAgICAgYXJyYXlfcHVzaCgkdG90YWxTY29yZTIsICRzY29yZSk7CiAgICAgICAgICAgIAogICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAyOgogICAgICAgICAgICBhcnJheV9wdXNoKCR0b3RhbFNjb3JlMywgJHNjb3JlKTsKICAgICAgICAgICAgICAgIAogICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgY2FzZSAzOgogICAgICAgICAgICBhcnJheV9wdXNoKCR0b3RhbFNjb3JlNCwgJHNjb3JlKTsKICAgICAgICAgICAgCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICBjYXNlIDQ6IAogICAgICAgICAgICBhcnJheV9wdXNoKCR0b3RhbFNjb3JlNSwgJHNjb3JlKTsKICAgICAgICAgICAgCiAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgJHJlc3VsdCA9IGNoZWNrQXJyYXkoJHRvdGFsU2NvcmUxKTsKICAgIAogICAgLy92YXJfZHVtcCgkdG90YWxTY29yZTFbMV0pOwp9CmZ1bmN0aW9uIGNoZWNrQXJyYXkoJHRvdGFsU2NvcmUpewogICAgCgogICAgCiAgICBmb3IoJGkgPSAwOyAkaSA8PSBjb3VudCgkdG90YWxTY29yZSk7ICRpICsrKXsKICAgICAgICAKICAgICAgICAkcmVzdWx0ID0gYXJyYXlfaW50ZXJzZWN0KCR0b3RhbFNjb3JlWyRpXSwgJHRvdGFsU2NvcmVbJGkrMV0pOwogICAgICAgIGlmKCFlbXB0eSgkcmVzdWx0KSl7CiAgICAgICAgICAgIHVuc2V0KCR0b3RhbFNjb3JlWyRpXSk7CiAgICAgICAgfQogICAgfQogICAgdmFyX2R1bXAoJHRvdGFsU2NvcmUpOwogICAgCiAgICAKICAgIAogICAgJHRvdGFsU2NvcmVVbmlxdWUgPSBhcnJheV91bmlxdWUoJHRvdGFsU2NvcmUpOwogICAgCiAgICBpZihjb3VudCgkdG90YWxTY29yZVVuaXF1ZSkgPiAxKXsKICAgICAgICAgCiAgICAgICAgJG1pbiA9IG1pbigkdG90YWxTY29yZVVuaXF1ZSk7CiAgICAgICAgdW5zZXQoJHRvdGFsU2NvcmVVbmlxdWVbYXJyYXlfc2VhcmNoKCRtaW4sICR0b3RhbFNjb3JlVW5pcXVlKV0pOwogICAgICAgIHJldHVybiAkdG90YWxTY29yZVVuaXF1ZTsKICAgIH0KICAgIHJldHVybiAkdG90YWxTY29yZVVuaXF1ZTsKfQoKCnJldHVybkpzb24oJGpzb25BcnJheSk7Cgo=