-4

这是我拥有的数组,它是 JSON 格式,但我也找到了 PHP 版本:

[{"client":"LawCapital ","placementID":"592952","creativeID":"728x90","dimensions":"728x90","impressions":39581,"bxd":4.854581,"viewable_impressions":11319,"exposure":54949,"viewability_rate":28.5970535,"clicks":344,"mouse_overs":4209},
{"client":"LawCapital ","placementID":"592951","creativeID":"300x250","dimensions":"300x250","impressions":31148,"bxd":4.58673525,"viewable_impressions":7373,"exposure":33818,"viewability_rate":23.6708622,"clicks":316,"mouse_overs":3495},
{"client":"LawCapital ","placementID":"592950","creativeID":"160x600","dimensions":"160x600","impressions":17538,"bxd":4.94013739,"viewable_impressions":4076,"exposure":20136,"viewability_rate":23.240963,"clicks":136,"mouse_overs":1792},
{"client":"MesaArtsCenter ","placementID":"569322","creativeID":"728x90","dimensions":"728x90","impressions":11564,"bxd":5.112021,"viewable_impressions":3785,"exposure":19349,"viewability_rate":32.73089,"clicks":15,"mouse_overs":1179},
{"client":"LawCapital ","placementID":"592952","creativeID":"728x90","dimensions":"728x90","impressions":9594,"bxd":4.61113167,"viewable_impressions":2695,"exposure":12427,"viewability_rate":28.0904732,"clicks":69,"mouse_overs":944},
{"client":"LawCapital ","placementID":"592951","creativeID":"300x250","dimensions":"300x250","impressions":7359,"bxd":4.609085,"viewable_impressions":1563,"exposure":7204,"viewability_rate":21.2392979,"clicks":64,"mouse_overs":778},
{"client":"SantanVW ","placementID":"589861","creativeID":"300x250","dimensions":"300x250","impressions":5251,"bxd":6.69421148,"viewable_impressions":2505,"exposure":16769,"viewability_rate":47.7052,"clicks":30,"mouse_overs":596},
{"client":"MesaArtsCenter ","placementID":"569317","creativeID":"300x250","dimensions":"300x250","impressions":5110,"bxd":5.541757,"viewable_impressions":1844,"exposure":10219,"viewability_rate":36.0861053,"clicks":5,"mouse_overs":537},
{"client":"MesaArtsCenter ","placementID":"569318","creativeID":"728x90","dimensions":"728x90","impressions":4545,"bxd":5.18741369,"viewable_impressions":1446,"exposure":7501,"viewability_rate":31.8151817,"clicks":12,"mouse_overs":485},
{"client":"MesaArtsCenter ","placementID":"569326","creativeID":"728x90","dimensions":"728x90","impressions":4474,"bxd":5.05910635,"viewable_impressions":1455,"exposure":7361,"viewability_rate":32.5212326,"clicks":16,"mouse_overs":606},
{"client":"MesaArtsCenter ","placementID":"569311","creativeID":"728x90","dimensions":"728x90","impressions":4323,"bxd":5.3496933,"viewable_impressions":1467,"exposure":7848,"viewability_rate":33.93477,"clicks":15,"mouse_overs":579},
{"client":"USRoadSports ","placementID":"572319","creativeID":"728x90","dimensions":"728x90","impressions":4074,"bxd":6.50550461,"viewable_impressions":2180,"exposure":14182,"viewability_rate":53.5100632,"clicks":31,"mouse_overs":659},
{"client":"LawCapital ","placementID":"592950","creativeID":"160x600","dimensions":"160x600","impressions":3921,"bxd":4.76361656,"viewable_impressions":918,"exposure":4373,"viewability_rate":23.4123955,"clicks":37,"mouse_overs":388},
{"client":"MesaArtsCenter ","placementID":"569320","creativeID":"300x250","dimensions":"300x250","impressions":3778,"bxd":5.0169363,"viewable_impressions":1299,"exposure":6517,"viewability_rate":34.38327,"clicks":4,"mouse_overs":357},
{"client":"USRoadSports ","placementID":"572315","creativeID":"300x250","dimensions":"300x250","impressions":3635,"bxd":6.169757,"viewable_impressions":1726,"exposure":10649,"viewability_rate":47.4828072,"clicks":3,"mouse_overs":109},
{"client":"MesaArtsCenter ","placementID":"569313","creativeID":"300x250","dimensions":"300x250","impressions":3616,"bxd":5.50813341,"viewable_impressions":1291,"exposure":7111,"viewability_rate":35.7024345,"clicks":2,"mouse_overs":354},
{"client":"USRoadSports ","placementID":"572319","creativeID":"728x90","dimensions":"728x90","impressions":3604,"bxd":5.5516305,"viewable_impressions":1472,"exposure":8172,"viewability_rate":40.8435059,"clicks":2,"mouse_overs":172},
{"client":"MesaArtsCenter ","placementID":"569324","creativeID":"300x250","dimensions":"300x250","impressions":3555,"bxd":5.68199825,"viewable_impressions":1261,"exposure":7165,"viewability_rate":35.47117,"clicks":0,"mouse_overs":389},
{"client":"USRoadSports ","placementID":"572315","creativeID":"300x250","dimensions":"300x250","impressions":3433,"bxd":6.916201,"viewable_impressions":1969,"exposure":13618,"viewability_rate":57.3550835,"clicks":17,"mouse_overs":345},
{"client":"MesaArtsCenter ","placementID":"569319","creativeID":"160x600","dimensions":"160x600","impressions":2730,"bxd":5.76276255,"viewable_impressions":999,"exposure":5757,"viewability_rate":36.5934067,"clicks":2,"mouse_overs":195},
{"client":"SantanVW ","placementID":"589862","creativeID":"160x600","dimensions":"160x600","impressions":2516,"bxd":6.09926748,"viewable_impressions":1229,"exposure":7496,"viewability_rate":48.8473778,"clicks":8,"mouse_overs":352},
{"client":"MesaArtsCenter ","placementID":"569312","creativeID":"160x600","dimensions":"160x600","impressions":1895,"bxd":5.69220257,"viewable_impressions":731,"exposure":4161,"viewability_rate":38.5752,"clicks":3,"mouse_overs":129},
{"client":"MesaArtsCenter ","placementID":"569323","creativeID":"160x600","dimensions":"160x600","impressions":1842,"bxd":5.71860838,"viewable_impressions":661,"exposure":3780,"viewability_rate":35.8849068,"clicks":2,"mouse_overs":116},
{"client":"USRoadSports ","placementID":"572311","creativeID":"160x600","dimensions":"160x600","impressions":1586,"bxd":6.43705654,"viewable_impressions":1128,"exposure":7261,"viewability_rate":71.12232,"clicks":1,"mouse_overs":73},
{"client":"USRoadSports ","placementID":"572311","creativeID":"160x600","dimensions":"160x600","impressions":1545,"bxd":7.901598,"viewable_impressions":1189,"exposure":9395,"viewability_rate":76.95793,"clicks":8,"mouse_overs":158},
{"client":"MesaArtsCenter ","placementID":"569315","creativeID":"160x600","dimensions":"160x600","impressions":1041,"bxd":5.91105127,"viewable_impressions":371,"exposure":2193,"viewability_rate":35.63881,"clicks":3,"mouse_overs":75},
{"client":"MesaArtsCenter ","placementID":"569317","creativeID":"300x250","dimensions":"300x250","impressions":665,"bxd":5.887324,"viewable_impressions":355,"exposure":2090,"viewability_rate":53.3834572,"clicks":0,"mouse_overs":51},
{"client":"MesaArtsCenter ","placementID":"569322","creativeID":"728x90","dimensions":"728x90","impressions":658,"bxd":6.363322,"viewable_impressions":289,"exposure":1839,"viewability_rate":43.92097,"clicks":1,"mouse_overs":62},
{"client":"Ztejas ","placementID":"570664","creativeID":"300x250","dimensions":"300x250","impressions":595,"bxd":6.64347839,"viewable_impressions":345,"exposure":2292,"viewability_rate":57.9831924,"clicks":0,"mouse_overs":33},
{"client":"Ztejas ","placementID":"564936","creativeID":"300x250","dimensions":"300x250","impressions":547,"bxd":6.412969,"viewable_impressions":293,"exposure":1879,"viewability_rate":53.5649,"clicks":0,"mouse_overs":42},
{"client":"Ztejas ","placementID":"564924","creativeID":"300x250","dimensions":"300x250","impressions":481,"bxd":6.61397076,"viewable_impressions":272,"exposure":1799,"viewability_rate":56.5488548,"clicks":0,"mouse_overs":33},
{"client":"MesaArtsCenter ","placementID":"569324","creativeID":"300x250","dimensions":"300x250","impressions":446,"bxd":5.62801933,"viewable_impressions":207,"exposure":1165,"viewability_rate":46.4125557,"clicks":1,"mouse_overs":43},
{"client":"MesaArtsCenter ","placementID":"569313","creativeID":"300x250","dimensions":"300x250","impressions":430,"bxd":5.77056265,"viewable_impressions":231,"exposure":1333,"viewability_rate":53.720932,"clicks":0,"mouse_overs":31},
{"client":"USRoadSports ","placementID":"572316","creativeID":"300x600","dimensions":"300x600","impressions":417,"bxd":6.36740351,"viewable_impressions":362,"exposure":2305,"viewability_rate":86.8105545,"clicks":0,"mouse_overs":22},
{"client":"Ztejas ","placementID":"570663","creativeID":"728x90","dimensions":"728x90","impressions":394,"bxd":6.181818,"viewable_impressions":187,"exposure":1156,"viewability_rate":47.46193,"clicks":3,"mouse_overs":32},
{"client":"Ztejas ","placementID":"564935","creativeID":"728x90","dimensions":"728x90","impressions":376,"bxd":6.09,"viewable_impressions":200,"exposure":1218,"viewability_rate":53.19149,"clicks":0,"mouse_overs":38},
{"client":"MesaArtsCenter ","placementID":"569311","creativeID":"728x90","dimensions":"728x90","impressions":376,"bxd":5.518072,"viewable_impressions":166,"exposure":916,"viewability_rate":44.1489372,"clicks":0,"mouse_overs":42},
{"client":"Ztejas ","placementID":"564950","creativeID":"300x250","dimensions":"300x250","impressions":361,"bxd":5.675824,"viewable_impressions":182,"exposure":1033,"viewability_rate":50.4155121,"clicks":0,"mouse_overs":21},
{"client":"Ztejas ","placementID":"564922","creativeID":"728x90","dimensions":"728x90","impressions":361,"bxd":6.29651165,"viewable_impressions":172,"exposure":1083,"viewability_rate":47.6454277,"clicks":0,"mouse_overs":34},
{"client":"Ztejas ","placementID":"564943","creativeID":"300x250","dimensions":"300x250","impressions":355,"bxd":6.49230766,"viewable_impressions":195,"exposure":1266,"viewability_rate":54.9295769,"clicks":1,"mouse_overs":28},
{"client":"MesaArtsCenter ","placementID":"569320","creativeID":"300x250","dimensions":"300x250","impressions":355,"bxd":5.52688169,"viewable_impressions":186,"exposure":1028,"viewability_rate":52.3943672,"clicks":0,"mouse_overs":20},
{"client":"MesaArtsCenter ","placementID":"569326","creativeID":"728x90","dimensions":"728x90","impressions":348,"bxd":4.86178875,"viewable_impressions":123,"exposure":598,"viewability_rate":35.3448257,"clicks":1,"mouse_overs":44},
{"client":"MesaArtsCenter ","placementID":"569318","creativeID":"728x90","dimensions":"728x90","impressions":338,"bxd":5.3396225,"viewable_impressions":159,"exposure":849,"viewability_rate":47.04142,"clicks":0,"mouse_overs":41},
{"client":"MesaArtsCenter ","placementID":"569319","creativeID":"160x600","dimensions":"160x600","impressions":334,"bxd":6.90751457,"viewable_impressions":173,"exposure":1195,"viewability_rate":51.7964058,"clicks":0,"mouse_overs":31},
{"client":"Ztejas ","placementID":"564941","creativeID":"728x90","dimensions":"728x90","impressions":277,"bxd":6.2421875,"viewable_impressions":128,"exposure":799,"viewability_rate":46.2093849,"clicks":0,"mouse_overs":31},
{"client":"Ztejas ","placementID":"564960","creativeID":"160x600","dimensions":"160x600","impressions":276,"bxd":6.83625746,"viewable_impressions":171,"exposure":1169,"viewability_rate":61.95652,"clicks":0,"mouse_overs":14},
{"client":"Ztejas ","placementID":"564966","creativeID":"160x600","dimensions":"160x600","impressions":250,"bxd":6.86075926,"viewable_impressions":158,"exposure":1084,"viewability_rate":63.2,"clicks":0,"mouse_overs":23},
{"client":"Ztejas ","placementID":"564962","creativeID":"160x600","dimensions":"160x600","impressions":230,"bxd":7.31847143,"viewable_impressions":157,"exposure":1149,"viewability_rate":68.26087,"clicks":0,"mouse_overs":24},
{"client":"MesaArtsCenter ","placementID":"569323","creativeID":"160x600","dimensions":"160x600","impressions":217,"bxd":6.1968503,"viewable_impressions":127,"exposure":787,"viewability_rate":58.5253448,"clicks":0,"mouse_overs":26},
{"client":"Ztejas ","placementID":"564952","creativeID":"728x90","dimensions":"728x90","impressions":213,"bxd":5.974359,"viewable_impressions":117,"exposure":699,"viewability_rate":54.9295769,"clicks":0,"mouse_overs":18},
{"client":"Ztejas ","placementID":"564961","creativeID":"160x600","dimensions":"160x600","impressions":180,"bxd":6.18852472,"viewable_impressions":122,"exposure":755,"viewability_rate":67.77778,"clicks":1,"mouse_overs":16},
{"client":"MesaArtsCenter ","placementID":"569315","creativeID":"160x600","dimensions":"160x600","impressions":180,"bxd":6.28282833,"viewable_impressions":99,"exposure":622,"viewability_rate":55,"clicks":0,"mouse_overs":16},
{"client":"MesaArtsCenter ","placementID":"569312","creativeID":"160x600","dimensions":"160x600","impressions":167,"bxd":6.419355,"viewable_impressions":93,"exposure":597,"viewability_rate":55.68862,"clicks":0,"mouse_overs":17},
{"client":"MesaArtsCenter ","placementID":"569590","creativeID":"300x600","dimensions":"300x600","impressions":156,"bxd":5.82926846,"viewable_impressions":82,"exposure":478,"viewability_rate":52.5641022,"clicks":0,"mouse_overs":45},
{"client":"MesaArtsCenter ","placementID":"569590","creativeID":"300x600","dimensions":"300x600","impressions":152,"bxd":6.32894754,"viewable_impressions":76,"exposure":481,"viewability_rate":50,"clicks":0,"mouse_overs":33},
{"client":"Ztejas ","placementID":"564955","creativeID":"300x250","dimensions":"300x250","impressions":136,"bxd":6.6811595,"viewable_impressions":69,"exposure":461,"viewability_rate":50.7352943,"clicks":0,"mouse_overs":7},
{"client":"MesaArtsCenter ","placementID":"569588","creativeID":"300x600","dimensions":"300x600","impressions":118,"bxd":5.467742,"viewable_impressions":62,"exposure":339,"viewability_rate":52.5423737,"clicks":0,"mouse_overs":39},
{"client":"Ztejas ","placementID":"564963","creativeID":"160x600","dimensions":"160x600","impressions":117,"bxd":5.608108,"viewable_impressions":74,"exposure":415,"viewability_rate":63.2478638,"clicks":0,"mouse_overs":8},
{"client":"MesaArtsCenter ","placementID":"569591","creativeID":"300x600","dimensions":"300x600","impressions":114,"bxd":6.05084753,"viewable_impressions":59,"exposure":357,"viewability_rate":51.7543869,"clicks":0,"mouse_overs":30},
{"client":"MesaArtsCenter ","placementID":"569591","creativeID":"300x600","dimensions":"300x600","impressions":93,"bxd":6.26,"viewable_impressions":50,"exposure":313,"viewability_rate":53.76344,"clicks":0,"mouse_overs":25},
{"client":"MesaArtsCenter ","placementID":"569588","creativeID":"300x600","dimensions":"300x600","impressions":87,"bxd":6.326087,"viewable_impressions":46,"exposure":291,"viewability_rate":52.87356,"clicks":0,"mouse_overs":28},
{"client":"MesaArtsCenter ","placementID":"569589","creativeID":"300x600","dimensions":"300x600","impressions":85,"bxd":5.56862736,"viewable_impressions":51,"exposure":284,"viewability_rate":60,"clicks":0,"mouse_overs":17},
{"client":"MesaArtsCenter ","placementID":"569589","creativeID":"300x600","dimensions":"300x600","impressions":74,"bxd":5.375,"viewable_impressions":32,"exposure":172,"viewability_rate":43.2432442,"clicks":0,"mouse_overs":20},
{"client":"Ztejas ","placementID":"564953","creativeID":"728x90","dimensions":"728x90","impressions":59,"bxd":7.32352924,"viewable_impressions":34,"exposure":249,"viewability_rate":57.6271172,"clicks":0,"mouse_overs":7},
{"client":"USRoadSports ","placementID":"572316","creativeID":"300x600","dimensions":"300x600","impressions":55,"bxd":8.689655,"viewable_impressions":29,"exposure":252,"viewability_rate":52.727272,"clicks":6,"mouse_overs":8},
{"client":"USRoadSports ","placementID":"572317","creativeID":"320x50","dimensions":"320x50","impressions":40,"bxd":6.909091,"viewable_impressions":11,"exposure":76,"viewability_rate":27.5,"clicks":0,"mouse_overs":1},
{"client":"Ztejas ","placementID":"564964","creativeID":"160x600","dimensions":"160x600","impressions":36,"bxd":6.77272749,"viewable_impressions":22,"exposure":149,"viewability_rate":61.11111,"clicks":0,"mouse_overs":5},
{"client":"Ztejas ","placementID":"570673","creativeID":"320x50","dimensions":"320x50","impressions":26,"bxd":5.25,"viewable_impressions":16,"exposure":84,"viewability_rate":61.53846,"clicks":0,"mouse_overs":3},
{"client":"Ztejas ","placementID":"570676","creativeID":"320x50","dimensions":"320x50","impressions":23,"bxd":8,"viewable_impressions":6,"exposure":48,"viewability_rate":26.086956,"clicks":0,"mouse_overs":1},
{"client":"MesaArtsCenter ","placementID":"569314","creativeID":"320x50","dimensions":"320x50","impressions":19,"bxd":3.42857146,"viewable_impressions":7,"exposure":24,"viewability_rate":36.8421059,"clicks":0,"mouse_overs":1},
{"client":"Ztejas ","placementID":"570674","creativeID":"320x50","dimensions":"320x50","impressions":19,"bxd":9.625,"viewable_impressions":8,"exposure":77,"viewability_rate":42.1052628,"clicks":0,"mouse_overs":2},
{"client":"Ztejas ","placementID":"570672","creativeID":"320x50","dimensions":"320x50","impressions":18,"bxd":5.66666651,"viewable_impressions":6,"exposure":34,"viewability_rate":33.3333321,"clicks":0,"mouse_overs":0},
{"client":"MesaArtsCenter ","placementID":"569316","creativeID":"320x50","dimensions":"320x50","impressions":18,"bxd":7.25,"viewable_impressions":8,"exposure":58,"viewability_rate":44.4444427,"clicks":0,"mouse_overs":1},
{"client":"MesaArtsCenter ","placementID":"569325","creativeID":"320x50","dimensions":"320x50","impressions":17,"bxd":8,"viewable_impressions":4,"exposure":32,"viewability_rate":23.5294113,"clicks":0,"mouse_overs":0},
{"client":"Ztejas ","placementID":"570671","creativeID":"320x50","dimensions":"320x50","impressions":15,"bxd":5.66666651,"viewable_impressions":6,"exposure":34,"viewability_rate":40,"clicks":0,"mouse_overs":1},
{"client":"Ztejas ","placementID":"570675","creativeID":"320x50","dimensions":"320x50","impressions":11,"bxd":8,"viewable_impressions":3,"exposure":24,"viewability_rate":27.272728,"clicks":0,"mouse_overs":0},
{"client":"MesaArtsCenter ","placementID":"569321","creativeID":"320x50","dimensions":"320x50","impressions":9,"bxd":6.75,"viewable_impressions":4,"exposure":27,"viewability_rate":44.4444427,"clicks":0,"mouse_overs":0},
{"client":"MesaArtsCenter ","placementID":"569321","creativeID":"320x50","dimensions":"320x50","impressions":8,"bxd":7.66666651,"viewable_impressions":3,"exposure":23,"viewability_rate":37.5,"clicks":0,"mouse_overs":0},
{"client":"Ztejas","placementID":"570669","creativeID":"320x50","dimensions":"320x50","impressions":8,"bxd":9.166667,"viewable_impressions":6,"exposure":55,"viewability_rate":75,"clicks":0,"mouse_overs":0},
{"client":"Ztejas ","placementID":"570667","creativeID":"320x50","dimensions":"320x50","impressions":7,"bxd":0,"viewable_impressions":0,"exposure":2,"viewability_rate":0,"clicks":0,"mouse_overs":1},
{"client":"USRoadSports","placementID":"572317","creativeID":"320x50","dimensions":"320x50","impressions":4,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0},
{"client":"Ztejas","placementID":"570668","creativeID":"320x50","dimensions":"320x50","impressions":3,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0},
{"client":"SantanVW ","placementID":"589862","creativeID":"160x600","dimensions":"160x600","impressions":3,"bxd":10,"viewable_impressions":2,"exposure":20,"viewability_rate":66.6666641,"clicks":0,"mouse_overs":0},
{"client":"SantanVW ","placementID":"589861","creativeID":"300x250","dimensions":"300x250","impressions":2,"bxd":8.5,"viewable_impressions":2,"exposure":17,"viewability_rate":100,"clicks":0,"mouse_overs":0},
{"client":"Ztejas ","placementID":"564965","creativeID":"160x600","dimensions":"160x600","impressions":2,"bxd":10,"viewable_impressions":2,"exposure":20,"viewability_rate":100,"clicks":0,"mouse_overs":2},
{"client":"MesaArtsCenter","placementID":"569325","creativeID":"320x50","dimensions":"320x50","impressions":2,"bxd":10,"viewable_impressions":1,"exposure":10,"viewability_rate":50,"clicks":0,"mouse_overs":0},
{"client":"MesaArtsCenter ","placementID":"569316","creativeID":"320x50","dimensions":"320x50","impressions":1,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0},
{"client":"MoreMazda ","placementID":"564996","creativeID":"300x250","dimensions":"300x250","impressions":1,"bxd":2,"viewable_impressions":1,"exposure":2,"viewability_rate":100,"clicks":0,"mouse_overs":0},
{"client":"BedfordSlims","placementID":"568842","creativeID":"728x90","dimensions":"728x90","impressions":1,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0},
{"client":"JenniferAdams ","placementID":"575096","creativeID":"728x90","dimensions":"728x90","impressions":1,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0},
{"client":"BTWConcerts ","placementID":"588093","creativeID":"728x90","dimensions":"728x90","impressions":1,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0},
{"client":"BTWConcerts","placementID":"588091","creativeID":"160x600","dimensions":"160x600","impressions":1,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":1},
{"client":"BTWConcerts","placementID":"588092","creativeID":"300x250","dimensions":"300x250","impressions":1,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0},
{"client":"BTWConcerts","placementID":"588093","creativeID":"728x90","dimensions":"728x90","impressions":1,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0},
{"client":"SummitMaleMedical ","placementID":"589425","creativeID":"160x600","dimensions":"160x600","impressions":1,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0},
{"client":"SummitMaleMedical ","placementID":"589427","creativeID":"728x90","dimensions":"728x90","impressions":1,"bxd":0,"viewable_impressions":0,"exposure":0,"viewability_rate":0,"clicks":0,"mouse_overs":0}]

我需要在 PHP 中为每个客户端添加点击次数、展示次数等的总和。我尝试了几种不同的方法,但我只能弄清楚如何获得总和。谢谢!

///////// 编辑 //////////

我尝试使用 foreach 循环,在其中将客户端与字符串进行匹配,但这只会给我一个客户端,而不是它们的列表及其匹配的展示次数。我完全不知所措。我不知道该怎么做。我是使用数组的新手。

统计数据是假的,但阵列的布局是真实的。

//////// PHP 数组 /////////

Array
(
    [0] => Array
        (
            [client] => LawCapital                                                                                                                                                                   
            [placementID] => 592952
            [creativeID] => 728x90
            [dimensions] => 728x90
            [impressions] => 39581
            [bxd] => 4.854581
            [viewable_impressions] => 11319
            [exposure] => 54949
            [viewability_rate] => 28.5970535
            [clicks] => 344
            [mouse_overs] => 4209
        )

    [1] => Array
        (
            [client] => LawCapital                                                                                                                                                                  
            [placementID] => 592951
            [creativeID] => 300x250
            [dimensions] => 300x250
            [impressions] => 31148
            [bxd] => 4.58673525
            [viewable_impressions] => 7373
            [exposure] => 33818
            [viewability_rate] => 23.6708622
            [clicks] => 316
            [mouse_overs] => 3495
        )

    [2] => Array
        (
            [client] => LawCapital                                                                                                                                                                  
            [placementID] => 592950
            [creativeID] => 160x600
            [dimensions] => 160x600
            [impressions] => 17538
            [bxd] => 4.94013739
            [viewable_impressions] => 4076
            [exposure] => 20136
            [viewability_rate] => 23.240963
            [clicks] => 136
            [mouse_overs] => 1792
        )
4

3 回答 3

0

首先,使用 to array flag 而不是 to object flag in json_decode

$array = json_decode($yourJson, true);

定义一个新数组,其中键是客户端,

遍历数组并将每一列添加到每个客户端的总和中:

foreach ($array as $key => $val) {
    if (!isset($sum[$val['client']]['impressions'])) {
        $sum[$val['client']]['impressions'] = 0;
    }

    $sum[$val['client']]['impressions'] += $val['impressions'];
    // Repeat with other columns
}

你最终会得到一个像这样的数组:

$sum['MesaArtsCenter ']['impressions'] = 1234;

这是未经测试的,但您将了解背后的想法并可以扩展自己。

如果样本数据是真实的,您是否有客户的许可才能发布他们的统计数据?

此代码有效: http : //codepad.org/9SwhEcKZ

Output: Array
(
    [LawCapital ] => Array
        (
            [impressions] => 105220
        )

    [MesaArtsCenter ] => Array
        (
            [impressions] => 11564
        )

)
于 2013-10-08T15:40:05.027 回答
0

我更改了 json 数组,请替换为您的,我只从您那里获取了 3 条记录,并将点击次数更改为 1、2、3,因此总点击次数 = 6

var foo = {
            sample: [{"client":"LawCapital ","placementID":"592952","creativeID":"728x90","dimensions":"728x90","impressions":39581,"bxd":4.854581,"viewable_impressions":11319,"exposure":54949,"viewability_rate":28.5970535,"clicks":1,"mouse_overs":4209},
    {"client":"LawCapital ","placementID":"592951","creativeID":"300x250","dimensions":"300x250","impressions":31148,"bxd":4.58673525,"viewable_impressions":7373,"exposure":33818,"viewability_rate":23.6708622,"clicks":2,"mouse_overs":3495},
    {"client":"LawCapital ","placementID":"592950","creativeID":"160x600","dimensions":"160x600","impressions":17538,"bxd":4.94013739,"viewable_impressions":4076,"exposure":20136,"viewability_rate":23.240963,"clicks":3,"mouse_overs":1792}
            ]
        },
        total = 0,  //initialize the variable
        sample = foo.sample,  //JSON element  or  object literal 
        i;
    for (i = 0; i < sample.length; i++) {  //Try to loop through the array
        total += sample[i].clicks; 
    }
    alert(total);  //get the total clicks 1+2+3 = 6
于 2013-10-08T15:44:39.963 回答
0

考虑到数据源是一个包含数据的 JSON 表示的字符串,生成的代码将是:

$array = json_decode($json, true); // Create an array of objects from JSON
$results = array(); // Initialize resulting array

foreach ($array as $item){

    // Initialize non-existing indexes in resulting array
    if (!isset($results[$item['client']]['impressions'])) $results[$item['client']]['impressions'] = 0; // Initialize non-existing indexes in resulting array
    if (!isset($results[$item['client']]['clicks'])) $results[$item['client']]['clicks'] = 0;

    // Add those numbers!
    $results[$item['client']]['impressions'] += $item['impressions'];
    $results[$item['client']]['clicks'] += $item['clicks'];

}

print_r ($results);

然后$results将是:

Array
(
[LawCapital ] => Array
    (
        [impressions] => 109141
        [clicks] => 966
    )

[MesaArtsCenter ] => Array
    (
        [impressions] => 53938
        [clicks] => 82
    )

[SantanVW ] => Array
    (
        [impressions] => 7772
        [clicks] => 38
...
于 2013-10-08T16:08:18.343 回答