<?php
function gen() {
$data = array();
$i = 0;
for($i; $i < 50; $i++) {
$data[$i] = array(
'indent' => 'test ' . $i,
'depth' => 1
);
}
return array();
}
echo serialize(gen());
/*
$array = array(
55 => array(
'ident' => 'test 1',
'depth' => 1,
),
77 => array(
'parent_id' => 55,
'ident' => 'test 2',
'depth' => 2,
),
109 => array(
'parent_id' => 77,
'ident' => 'test 3',
'depth' => 3,
),
78 => array(
'parent_id' => 55,
'ident' => 'test 4',
'depth' => 2,
),
25 => array(
'ident' => 'test 5',
'depth' => 1,
)
);
*/
$array = unserialize('a:0:{}');
/*
function v1($array) {
foreach ($array as $key => &$sub) {
if (isset($sub['parent_id'])) {
$array[$sub['parent_id']]['children'][$key] = &$sub;
}
}
unset($sub); // unset the reference to make sure to not overwrite it later...
// now remove the entries with parents
foreach ($array as $key => $sub) {
if (isset($sub['parent_id']))
unset($array[$key]);
}
return $array;
}
function push_at_key($what, $what_key, $key, $array) {
foreach($array as $k => $v) {
if($key == $k) {
$array[$k]['children'][$what_key] = $what;
return $array;
}
}
foreach($array as $k => $v) {
$array[$k] = push_at_key($what, $what_key, $key, $v['children']);
}
return $array;
}
function v2($array) {
$out = array();
foreach ($array as $key => $sub) {
if(!isset($sub['parent_id'])) {
$out[$key] = $sub;
}
else {
$out = push_at_key($sub, $key, $sub['parent_id'], $out);
}
}
return $out;
}
//var_dump(v1($array));
//var_dump(v2($array));
*/
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename: /in/KcqV0
function name: (null)
number of ops: 11
compiled vars: !0 = $array
line #* E I O op fetch ext return operands
-------------------------------------------------------------------------------------
18 0 E > INIT_FCALL 'serialize'
1 INIT_FCALL 'gen'
2 DO_FCALL 0 $1
3 SEND_VAR $1
4 DO_ICALL $2
5 ECHO $2
47 6 INIT_FCALL 'unserialize'
7 SEND_VAL 'a%3A0%3A%7B%7D'
8 DO_ICALL $3
9 ASSIGN !0, $3
98 10 > RETURN 1
Function gen:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 3
2 jumps found. (Code = 44) Position 1 = 11, Position 2 = 3
Branch analysis from position: 11
Branch analysis from position: 3
filename: /in/KcqV0
function name: gen
number of ops: 13
compiled vars: !0 = $data, !1 = $i
line #* E I O op fetch ext return operands
-------------------------------------------------------------------------------------
4 0 E > ASSIGN !0, <array>
6 1 ASSIGN !1, 0
8 2 > JMP ->9
10 3 > CONCAT ~5 'test+', !1
4 INIT_ARRAY ~6 ~5, 'indent'
11 5 ADD_ARRAY_ELEMENT ~6 1, 'depth'
9 6 ASSIGN_DIM !0, !1
11 7 OP_DATA ~6
8 8 PRE_INC !1
9 > IS_SMALLER !1, 50
10 > JMPNZ ~8, ->3
15 11 > > RETURN <array>
16 12* > RETURN null
End of function gen
Generated using Vulcan Logic Dumper, using php 8.0.0
preferences:
156.28 ms | 1399 KiB | 18 Q