3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = [ ['Template' => 'page.html5'], ['Template' => 'page2.html5'], ['Template' => 'page.html5'], ['Template' => 'page2.html5'], ['Template' => 'page.html5'], ['Template' => 'page2.html5'], ['id' => 27, 'table' => 'tl_custom', 'type' => 'text', 'data' => [ 'fragment' => 'example', 'previewId' => 1, 'isActive' => 1, ], ] ]; $newArr = array_unique(array_map(function ($el) { return $el['Template'] ?? serialize($el); }, $arr)); // restore the last element to array $last = array_key_last($newArr); $newArr[$last] = unserialize($newArr[$last]); echo '<pre>'; print_r($newArr); echo '</pre>';
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4kDiP
function name:  (null)
number of ops:  26
compiled vars:  !0 = $arr, !1 = $newArr, !2 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   20     1        INIT_FCALL                                               'array_unique'
          2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                          ~4      [0]
   22     4        SEND_VAL                                                 ~4
          5        SEND_VAR                                                 !0
   20     6        DO_ICALL                                         $5      
   22     7        SEND_VAR                                                 $5
   20     8        DO_ICALL                                         $6      
          9        ASSIGN                                                   !1, $6
   25    10        INIT_FCALL                                               'array_key_last'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $8      
         13        ASSIGN                                                   !2, $8
   26    14        INIT_FCALL                                               'unserialize'
         15        FETCH_DIM_R                                      ~11     !1, !2
         16        SEND_VAL                                                 ~11
         17        DO_ICALL                                         $12     
         18        ASSIGN_DIM                                               !1, !2
         19        OP_DATA                                                  $12
   28    20        ECHO                                                     '%3Cpre%3E'
   29    21        INIT_FCALL                                               'print_r'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
   30    24        ECHO                                                     '%3C%2Fpre%3E'
         25      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4kDiP
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $el
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   21     1        FETCH_DIM_IS                                     ~1      !0, 'Template'
          2        COALESCE                                         ~2      ~1
          3        INIT_FCALL                                               'serialize'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $3      
          6        QM_ASSIGN                                        ~2      $3
          7      > RETURN                                                   ~2
   22     8*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.75 ms | 1008 KiB | 19 Q