3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( 82 => array ( 'APBKID' => '83', 'KodeRekening' => '3', 'LevelRekening' => NULL, 'KodeRekeningInduk' => NULL, 'Uraian' => 'PEMBIAYAAN', 'Anggaran' => '0', 'Keterangan' => NULL, 'TahunAnggaran' => '2019', 'KampungID' => '1', 'DanaDesa' => NULL, 'AlokasiDanaDesa' => NULL, 'CreatedAt' => '2019-08-10 18: 20: 36', 'CreatedBy' => '1', 'UpdatedAt' => '2019-09-06 12: 31: 21', 'UpdatedBy' => '1', 'Deleted' => '0', 'DistrikID' => '1', 'NamaKampung' => 'Amungun', 'KepalaKampung' => 'Joni Niwilingame', 'FotoKepalaKampung' => '', 'KodeRegisterKampung' => '91.09.02', 'GambarKampung' => 'splash.jpg', 'ProfilKampung' => '<p><strong style="margin: 0px; padding: 0px; font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">Lorem Ipsum</strong><span style="font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span><br></p>', ), 83 => array ( 'APBKID' => '84', 'KodeRekening' => '3.1', 'LevelRekening' => NULL, 'KodeRekeningInduk' => NULL, 'Uraian' => 'Penerimaan Pembiayaan ', 'Anggaran' => '99475000', 'Keterangan' => NULL, 'TahunAnggaran' => '2019', 'KampungID' => '1', 'DanaDesa' => NULL, 'AlokasiDanaDesa' => NULL, 'CreatedAt' => '2019-08-10 18: 20: 36', 'CreatedBy' => '1', 'UpdatedAt' => '2019-09-06 12: 31: 21', 'UpdatedBy' => '1', 'Deleted' => '0', 'DistrikID' => '1', 'NamaKampung' => 'Amungun', 'KepalaKampung' => 'Joni Niwilingame', 'FotoKepalaKampung' => '', 'KodeRegisterKampung' => '91.09.02', 'GambarKampung' => 'splash.jpg', 'ProfilKampung' => '<p><strong style="margin: 0px; padding: 0px; font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">Lorem Ipsum</strong><span style="font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span><br></p>', ), 84 => array ( 'APBKID' => '85', 'KodeRekening' => '3.1.1', 'LevelRekening' => NULL, 'KodeRekeningInduk' => NULL, 'Uraian' => 'SILPA ', 'Anggaran' => '99475000', 'Keterangan' => NULL, 'TahunAnggaran' => '2019', 'KampungID' => '1', 'DanaDesa' => NULL, 'AlokasiDanaDesa' => NULL, 'CreatedAt' => '2019-08-10 18: 20: 36', 'CreatedBy' => '1', 'UpdatedAt' => '2019-09-06 12: 31: 21', 'UpdatedBy' => '1', 'Deleted' => '0', 'DistrikID' => '1', 'NamaKampung' => 'Amungun', 'KepalaKampung' => 'Joni Niwilingame', 'FotoKepalaKampung' => '', 'KodeRegisterKampung' => '91.09.02', 'GambarKampung' => 'splash.jpg', 'ProfilKampung' => '<p><strong style="margin: 0px; padding: 0px; font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">Lorem Ipsum</strong><span style="font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span><br></p>', ), 85 => array ( 'APBKID' => '86', 'KodeRekening' => '3.1.2', 'LevelRekening' => NULL, 'KodeRekeningInduk' => NULL, 'Uraian' => 'Pencairan Dana Cadangan ', 'Anggaran' => '0', 'Keterangan' => NULL, 'TahunAnggaran' => '2019', 'KampungID' => '1', 'DanaDesa' => NULL, 'AlokasiDanaDesa' => NULL, 'CreatedAt' => '2019-08-10 18: 20: 36', 'CreatedBy' => '1', 'UpdatedAt' => '2019-09-06 12: 31: 21', 'UpdatedBy' => '1', 'Deleted' => '0', 'DistrikID' => '1', 'NamaKampung' => 'Amungun', 'KepalaKampung' => 'Joni Niwilingame', 'FotoKepalaKampung' => '', 'KodeRegisterKampung' => '91.09.02', 'GambarKampung' => 'splash.jpg', 'ProfilKampung' => '<p><strong style="margin: 0px; padding: 0px; font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">Lorem Ipsum</strong><span style="font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span><br></p>', ), 86 => array ( 'APBKID' => '87', 'KodeRekening' => '3.1.3', 'LevelRekening' => NULL, 'KodeRekeningInduk' => NULL, 'Uraian' => 'Hasil Kekayaan Desa Yang dipisahkan ', 'Anggaran' => '0', 'Keterangan' => NULL, 'TahunAnggaran' => '2019', 'KampungID' => '1', 'DanaDesa' => NULL, 'AlokasiDanaDesa' => NULL, 'CreatedAt' => '2019-08-10 18: 20: 36', 'CreatedBy' => '1', 'UpdatedAt' => '2019-09-06 12: 31: 21', 'UpdatedBy' => '1', 'Deleted' => '0', 'DistrikID' => '1', 'NamaKampung' => 'Amungun', 'KepalaKampung' => 'Joni Niwilingame', 'FotoKepalaKampung' => '', 'KodeRegisterKampung' => '91.09.02', 'GambarKampung' => 'splash.jpg', 'ProfilKampung' => '<p><strong style="margin: 0px; padding: 0px; font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">Lorem Ipsum</strong><span style="font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span><br></p>', ), 87 => array ( 'APBKID' => '88', 'KodeRekening' => '3.2', 'LevelRekening' => NULL, 'KodeRekeningInduk' => NULL, 'Uraian' => 'Pengeluaran Pembiayaan ', 'Anggaran' => '0', 'Keterangan' => NULL, 'TahunAnggaran' => '2019', 'KampungID' => '1', 'DanaDesa' => NULL, 'AlokasiDanaDesa' => NULL, 'CreatedAt' => '2019-08-10 18: 20: 36', 'CreatedBy' => '1', 'UpdatedAt' => '2019-09-06 12: 31: 21', 'UpdatedBy' => '1', 'Deleted' => '0', 'DistrikID' => '1', 'NamaKampung' => 'Amungun', 'KepalaKampung' => 'Joni Niwilingame', 'FotoKepalaKampung' => '', 'KodeRegisterKampung' => '91.09.02', 'GambarKampung' => 'splash.jpg', 'ProfilKampung' => '<p><strong style="margin: 0px; padding: 0px; font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">Lorem Ipsum</strong><span style="font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span><br></p>', ), 88 => array ( 'APBKID' => '89', 'KodeRekening' => '3.2.1', 'LevelRekening' => NULL, 'KodeRekeningInduk' => NULL, 'Uraian' => 'Pembentukan Dana Cadangan ', 'Anggaran' => '0', 'Keterangan' => NULL, 'TahunAnggaran' => '2019', 'KampungID' => '1', 'DanaDesa' => NULL, 'AlokasiDanaDesa' => NULL, 'CreatedAt' => '2019-08-10 18: 20: 36', 'CreatedBy' => '1', 'UpdatedAt' => '2019-09-06 12: 31: 21', 'UpdatedBy' => '1', 'Deleted' => '0', 'DistrikID' => '1', 'NamaKampung' => 'Amungun', 'KepalaKampung' => 'Joni Niwilingame', 'FotoKepalaKampung' => '', 'KodeRegisterKampung' => '91.09.02', 'GambarKampung' => 'splash.jpg', 'ProfilKampung' => '<p><strong style="margin: 0px; padding: 0px; font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">Lorem Ipsum</strong><span style="font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span><br></p>', ), 89 => array ( 'APBKID' => '90', 'KodeRekening' => '3.2.2', 'LevelRekening' => NULL, 'KodeRekeningInduk' => NULL, 'Uraian' => 'Penyertaan Modal Desa ', 'Anggaran' => '0', 'Keterangan' => NULL, 'TahunAnggaran' => '2019', 'KampungID' => '1', 'DanaDesa' => NULL, 'AlokasiDanaDesa' => NULL, 'CreatedAt' => '2019-08-10 18: 20: 36', 'CreatedBy' => '1', 'UpdatedAt' => '2019-09-06 12: 31: 21', 'UpdatedBy' => '1', 'Deleted' => '0', 'DistrikID' => '1', 'NamaKampung' => 'Amungun', 'KepalaKampung' => 'Joni Niwilingame', 'FotoKepalaKampung' => '', 'KodeRegisterKampung' => '91.09.02', 'GambarKampung' => 'splash.jpg', 'ProfilKampung' => '<p><strong style="margin: 0px; padding: 0px; font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">Lorem Ipsum</strong><span style="font-family: &quot;Open Sans&quot;, Arial, sans-serif; text-align: justify;">&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</span><br></p>', ) ); usort($arr,function($array1,$array2){ $version_1 = explode(".",$array1['KodeRekening']); $version_2 = explode(".",$array2['KodeRekening']); $size_1 = count($version_1); $size_2 = count($version_2); $min_size = min($size_1,$size_2); for($i=0;$i<$min_size;++$i){ if(intval($version_1[$i]) < intval($version_2[$i])){ return -1; }else if(intval($version_1[$i]) > intval($version_2[$i])){ return 1; } } return $size_1 - $size_2; }); $set = []; $result = []; foreach($arr as $curr){ $version = $curr['KodeRekening']; $parent_version = implode(".",array_slice(explode(".",$version),0,-1)); if(isset($set[$parent_version])){ $parent_element = &$set[$parent_version]; if(!isset($parent_element['data'])) $parent_element['data'] = []; $parent_element['data'][] = $curr; $set[$version] = &$parent_element['data'][lastIndex($parent_element['data'])]; }else{ $result[] = $curr; $set[$version] = &$result[lastIndex($result)]; } } function lastIndex($arr){ $keys = array_keys($arr); return end($keys); } print_r($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 59
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 59
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 49
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 35
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
filename:       /in/U4ssp
function name:  (null)
number of ops:  64
compiled vars:  !0 = $arr, !1 = $set, !2 = $result, !3 = $curr, !4 = $version, !5 = $parent_version, !6 = $parent_element
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
  215     1        INIT_FCALL                                               'usort'
          2        SEND_REF                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FU4ssp%3A215%240'
  233     4        SEND_VAL                                                 ~8
          5        DO_ICALL                                                 
  235     6        ASSIGN                                                   !1, <array>
  236     7        ASSIGN                                                   !2, <array>
  238     8      > FE_RESET_R                                       $12     !0, ->59
          9    > > FE_FETCH_R                                               $12, !3, ->59
  239    10    >   FETCH_DIM_R                                      ~13     !3, 'KodeRekening'
         11        ASSIGN                                                   !4, ~13
  240    12        INIT_FCALL                                               'implode'
         13        SEND_VAL                                                 '.'
         14        INIT_FCALL                                               'array_slice'
         15        INIT_FCALL                                               'explode'
         16        SEND_VAL                                                 '.'
         17        SEND_VAR                                                 !4
         18        DO_ICALL                                         $15     
         19        SEND_VAR                                                 $15
         20        SEND_VAL                                                 0
         21        SEND_VAL                                                 -1
         22        DO_ICALL                                         $16     
         23        SEND_VAR                                                 $16
         24        DO_ICALL                                         $17     
         25        ASSIGN                                                   !5, $17
  242    26        ISSET_ISEMPTY_DIM_OBJ                         0          !1, !5
         27      > JMPZ                                                     ~19, ->49
  243    28    >   FETCH_DIM_W                                      $20     !1, !5
         29        ASSIGN_REF                                               !6, $20
  244    30        ISSET_ISEMPTY_DIM_OBJ                         0  ~22     !6, 'data'
         31        BOOL_NOT                                         ~23     ~22
         32      > JMPZ                                                     ~23, ->35
         33    >   ASSIGN_DIM                                               !6, 'data'
         34        OP_DATA                                                  <array>
  245    35    >   FETCH_DIM_W                                      $25     !6, 'data'
         36        ASSIGN_DIM                                               $25
         37        OP_DATA                                                  !3
  246    38        INIT_FCALL_BY_NAME                                       'lastIndex'
         39        CHECK_FUNC_ARG                                           
         40        FETCH_DIM_FUNC_ARG                               $29     !6, 'data'
         41        SEND_FUNC_ARG                                            $29
         42        DO_FCALL                                      0  $30     
         43        FETCH_DIM_W                                      $28     !6, 'data'
         44        FETCH_DIM_W                                      $31     $28, $30
         45        MAKE_REF                                         $32     $31
         46        FETCH_DIM_W                                      $27     !1, !4
         47        ASSIGN_REF                                               $27, $32
         48      > JMP                                                      ->58
  248    49    >   ASSIGN_DIM                                               !2
         50        OP_DATA                                                  !3
  249    51        INIT_FCALL_BY_NAME                                       'lastIndex'
         52        SEND_VAR_EX                                              !2
         53        DO_FCALL                                      0  $36     
         54        FETCH_DIM_W                                      $37     !2, $36
         55        MAKE_REF                                         $38     $37
         56        FETCH_DIM_W                                      $35     !1, !4
         57        ASSIGN_REF                                               $35, $38
  238    58    > > JMP                                                      ->9
         59    >   FE_FREE                                                  $12
  259    60        INIT_FCALL                                               'print_r'
         61        SEND_VAR                                                 !2
         62        DO_ICALL                                                 
         63      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FU4ssp%3A215%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 25
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 40
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 25
Branch analysis from position: 43
Branch analysis from position: 25
filename:       /in/U4ssp
function name:  {closure}
number of ops:  46
compiled vars:  !0 = $array1, !1 = $array2, !2 = $version_1, !3 = $version_2, !4 = $size_1, !5 = $size_2, !6 = $min_size, !7 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  215     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  216     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '.'
          4        FETCH_DIM_R                                      ~8      !0, 'KodeRekening'
          5        SEND_VAL                                                 ~8
          6        DO_ICALL                                         $9      
          7        ASSIGN                                                   !2, $9
  217     8        INIT_FCALL                                               'explode'
          9        SEND_VAL                                                 '.'
         10        FETCH_DIM_R                                      ~11     !1, 'KodeRekening'
         11        SEND_VAL                                                 ~11
         12        DO_ICALL                                         $12     
         13        ASSIGN                                                   !3, $12
  219    14        COUNT                                            ~14     !2
         15        ASSIGN                                                   !4, ~14
  220    16        COUNT                                            ~16     !3
         17        ASSIGN                                                   !5, ~16
  222    18        INIT_FCALL                                               'min'
         19        SEND_VAR                                                 !4
         20        SEND_VAR                                                 !5
         21        DO_ICALL                                         $18     
         22        ASSIGN                                                   !6, $18
  224    23        ASSIGN                                                   !7, 0
         24      > JMP                                                      ->41
  225    25    >   FETCH_DIM_R                                      ~21     !2, !7
         26        CAST                                          4  ~22     ~21
         27        FETCH_DIM_R                                      ~23     !3, !7
         28        CAST                                          4  ~24     ~23
         29        IS_SMALLER                                               ~22, ~24
         30      > JMPZ                                                     ~25, ->33
  226    31    > > RETURN                                                   -1
         32*       JMP                                                      ->40
  227    33    >   FETCH_DIM_R                                      ~26     !2, !7
         34        CAST                                          4  ~27     ~26
         35        FETCH_DIM_R                                      ~28     !3, !7
         36        CAST                                          4  ~29     ~28
         37        IS_SMALLER                                               ~29, ~27
         38      > JMPZ                                                     ~30, ->40
  228    39    > > RETURN                                                   1
  224    40    >   PRE_INC                                                  !7
         41    >   IS_SMALLER                                               !7, !6
         42      > JMPNZ                                                    ~32, ->25
  232    43    >   SUB                                              ~33     !4, !5
         44      > RETURN                                                   ~33
  233    45*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FU4ssp%3A215%240

Function lastindex:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/U4ssp
function name:  lastIndex
number of ops:  10
compiled vars:  !0 = $arr, !1 = $keys
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  254     0  E >   RECV                                             !0      
  255     1        INIT_FCALL                                               'array_keys'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !1, $2
  256     5        INIT_FCALL                                               'end'
          6        SEND_REF                                                 !1
          7        DO_ICALL                                         $4      
          8      > RETURN                                                   $4
  257     9*     > RETURN                                                   null

End of function lastindex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.66 ms | 1408 KiB | 29 Q