3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $response = array(); $formatedData = array(); $labels = array(); $results[] = new stdClass; $results[] = new stdClass; $results[] = new stdClass; $results[] = new stdClass; $results[] = new stdClass; $results[] = new stdClass; $results[] = new stdClass; $results[] = new stdClass; $results[] = new stdClass; $results[] = new stdClass; $results[] = new stdClass; $results[0]->day = "27 Jan"; $results[0]->stats = "DNS"; $results[0]->numAttacks = 4; $results[1]->day = "27 Jan"; $results[1]->stats = "Web"; $results[1]->numAttacks = 5; $results[2]->day = "27 Jan"; $results[2]->stats = "TCP"; $results[2]->numAttacks = 8; $results[3]->day = "28 Jan"; $results[3]->stats = "Web"; $results[3]->numAttacks = 4; $results[4]->day = "28 Jan"; $results[4]->stats = "DNS"; $results[4]->numAttacks = 2; $results[5]->day = "28 Jan"; $results[5]->stats = "TCP"; $results[5]->numAttacks = 6; $results[6]->day = "28 Jan"; $results[6]->stats = "SSL"; $results[6]->numAttacks = 7; $results[7]->day = "28 Jan"; $results[7]->stats = "SQL"; $results[7]->numAttacks = 3; $results[8]->day = "29 Jan"; $results[8]->stats = "Web"; $results[8]->numAttacks = 2; $results[9]->day = "29 Jan"; $results[9]->stats = "SQL"; $results[9]->numAttacks = 6; $results[10]->day = "30 Jan"; $results[10]->stats = "Web"; $results[10]->numAttacks = 8; //print_r($results); foreach ($results as $key => $value) { array_push($labels, "'".$value->day."'"); $formatedData[$value->stats]['numAttacks'][] = $value->numAttacks; $formatedData[$value->stats]['day'][] = $value->day; } //print_r($labels); //print_r($formatedData); $days = count($labels); $i = 1; foreach ($formatedData as $attacktype => $records) { echo $attacktype . "\n"; echo $records['numAttacks']; } ?>
based on 5oNYI
Output for 5.4.0 - 7.2.0
DNS Notice: Array to string conversion in /in/46WUh on line 82 ArrayWeb Notice: Array to string conversion in /in/46WUh on line 82 ArrayTCP Notice: Array to string conversion in /in/46WUh on line 82 ArraySSL Notice: Array to string conversion in /in/46WUh on line 82 ArraySQL Notice: Array to string conversion in /in/46WUh on line 82 Array
Output for 4.3.0 - 5.3.29
DNS ArrayWeb ArrayTCP ArraySSL ArraySQL Array