Advertisement
Guest User

Untitled

a guest
Jan 17th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. <?php
  2. $weas = [
  3.     [
  4.         'ip_address' => '170.239.86.148',
  5.         'central_report' => 'b.barracudacentral.org',
  6.         'status_ip' => 'blocked',
  7.         'fecha_status' => '2018-01-18',
  8.     ],
  9.     [
  10.         'ip_address' => '186.64.123.67',
  11.         'central_report' => 'b.barracudacentral.org',
  12.         'status_ip' => 'blocked',
  13.         'fecha_status' => '2018-01-18',
  14.     ],
  15.     [
  16.         'ip_address' => '186.64.123.67',
  17.         'central_report' => 'cbl.abuseat.org',
  18.         'status_ip' => 'blocked',
  19.         'fecha_status' => '2018-01-18',
  20.     ],
  21.     [
  22.         'ip_address' => '186.64.123.67',
  23.         'central_report' => 'spam.dnsbl.sorbs.net',
  24.         'status_ip' => 'blocked',
  25.         'fecha_status' => '2018-01-18',
  26.     ]
  27. ];
  28.  
  29. $datos = [];
  30.  
  31. foreach ($weas as $valor) {
  32.     $ip = $valor['ip_address'];
  33.     $central = $valor['central_report'];
  34.  
  35.     if (!array_key_exists($ip, $datos)) {
  36.         $datos[$ip]['central'] = [];
  37.     }
  38.  
  39.     $datos[$ip]['central'][] = $central;
  40. }
  41.  
  42. var_dump($datos);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement