<?php
$arrayA = array(
0 =>
array(
'id' => 4701,
'start' => '2018-04-15 17:00:00',
'start2' => '2018-04-15 19:00:00',
'expiry' => '2018-04-16 01:00:00',
'expiry2' => '2018-05-16 03:00:00',
'threat' => 'Rain',
'level' => 2,
'last_updated' => '2018-05-09 14:11:54',
'created' => '2018-04-12 15:05:50',
'county' => 'Luzerne',
'state' => 'Pennsylvania',
'image' => '15238041824facec0b183878da58e007b4b6.png',
),
1 =>
array(
'id' => 4947,
'start' => '2018-04-26 11:11:00',
'start2' => '2018-04-26 15:10:00',
'expiry' => '2018-04-30 23:00:00',
'expiry2' => '2018-05-30 08:00:00',
'threat' => 'Thunderstorm',
'level' => 3,
'last_updated' => '2018-05-09 12:33:25',
'created' => '2018-04-26 15:11:45',
'county' => 'Yellowstone',
'state' => 'Montana',
'image' => '1524755505c1beae47ebbb285beaa6a1c672.png',
),
2 =>
array(
'id' => 4947,
'start' => '2018-04-26 11:11:00',
'start2' => '2018-04-26 15:10:00',
'expiry' => '2018-04-30 23:00:00',
'expiry2' => '2018-05-30 08:00:00',
'threat' => 'Thunderstorm',
'level' => 3,
'last_updated' => '2018-05-09 12:33:25',
'created' => '2018-04-26 15:11:45',
'county' => 'Luzerne',
'state' => 'Pennsylvania',
'image' => '1524755505c1beae47ebbb285beaa6a1c672.png',
),
);
#print_r($arrayA);
#echo "\n\r";
#echo "Looking to turn the above array into the array below:\n\r";
#print_r($arrayB);
$result = [];
foreach ($arrayA as $row) {
$id = $row['id'];
if (!isset($result[$id])) {
$result[$id] = $row;
$result[$id]['affected_locations'] = [];
}
$result[$id]['affected_locations'] []= $row;
}
$arrayB = array_values($result);
print_r($arrayB);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 19
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 14
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 14
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename: /in/XmmQJ
function name: (null)
number of ops: 28
compiled vars: !0 = $arrayA, !1 = $result, !2 = $row, !3 = $id, !4 = $arrayB
line #* E I O op fetch ext return operands
-------------------------------------------------------------------------------------
3 0 E > ASSIGN !0, <array>
57 1 ASSIGN !1, <array>
58 2 > FE_RESET_R $7 !0, ->19
3 > > FE_FETCH_R $7, !2, ->19
59 4 > FETCH_DIM_R ~8 !2, 'id'
5 ASSIGN !3, ~8
60 6 ISSET_ISEMPTY_DIM_OBJ 0 ~10 !1, !3
7 BOOL_NOT ~11 ~10
8 > JMPZ ~11, ->14
61 9 > ASSIGN_DIM !1, !3
10 OP_DATA !2
62 11 FETCH_DIM_W $13 !1, !3
12 ASSIGN_DIM $13, 'affected_locations'
13 OP_DATA <array>
64 14 > FETCH_DIM_W $15 !1, !3
15 FETCH_DIM_W $16 $15, 'affected_locations'
16 ASSIGN_DIM $16
17 OP_DATA !2
58 18 > JMP ->3
19 > FE_FREE $7
67 20 INIT_FCALL 'array_values'
21 SEND_VAR !1
22 DO_ICALL $18
23 ASSIGN !4, $18
68 24 INIT_FCALL 'print_r'
25 SEND_VAR !4
26 DO_ICALL
27 > RETURN 1
Generated using Vulcan Logic Dumper, using php 8.0.0
preferences:
168.12 ms | 1396 KiB | 17 Q