3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Your code here! use Illuminate\Support\Collection; $word_list = ["banana", "peach", "banana", "berry", "grape", "melon", "orange", "apple", "banana","apple"]; $word_list2 = []; foreach ($word_list as $word){ $words_collection = collect(); $words_collection->put('word', $word); $words_collection->put('score', 5); array_push($word_list2, $word); } // continue; // } // array_push($words_rank, array("word"=>$word, "appear_of_num"=>$words_rank[$word]["appear_of_num"] + 1)); // } $words_rank = array_count_values($word_list2); // print_r($words_rank); arsort($words_rank); // print_r($words_rank); print_r(array_slice($words_rank, 0, 5)); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/D7NKD
function name:  (null)
number of ops:  37
compiled vars:  !0 = $word_list, !1 = $word_list2, !2 = $word, !3 = $words_collection, !4 = $words_rank
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   11     2      > FE_RESET_R                                       $7      !0, ->20
          3    > > FE_FETCH_R                                               $7, !2, ->20
   12     4    >   INIT_FCALL_BY_NAME                                       'collect'
          5        DO_FCALL                                      0  $8      
          6        ASSIGN                                                   !3, $8
   13     7        INIT_METHOD_CALL                                         !3, 'put'
          8        SEND_VAL_EX                                              'word'
          9        SEND_VAR_EX                                              !2
         10        DO_FCALL                                      0          
   14    11        INIT_METHOD_CALL                                         !3, 'put'
         12        SEND_VAL_EX                                              'score'
         13        SEND_VAL_EX                                              5
         14        DO_FCALL                                      0          
   16    15        INIT_FCALL                                               'array_push'
         16        SEND_REF                                                 !1
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   11    19      > JMP                                                      ->3
         20    >   FE_FREE                                                  $7
   26    21        INIT_FCALL                                               'array_count_values'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $13     
         24        ASSIGN                                                   !4, $13
   29    25        INIT_FCALL                                               'arsort'
         26        SEND_REF                                                 !4
         27        DO_ICALL                                                 
   33    28        INIT_FCALL                                               'print_r'
         29        INIT_FCALL                                               'array_slice'
         30        SEND_VAR                                                 !4
         31        SEND_VAL                                                 0
         32        SEND_VAL                                                 5
         33        DO_ICALL                                         $16     
         34        SEND_VAR                                                 $16
         35        DO_ICALL                                                 
   36    36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.14 ms | 1396 KiB | 23 Q