3v4l.org

run code in 300+ PHP versions simultaneously
<?php // собираем массив с юзерами $arr = ['вася','петя','ваня','ира','лена','маша','маша','вася','ваня','света','ваня']; // формируем строку $str = implode('|', $arr); // для результата $res = []; foreach($arr as $key){ // проверяем сколько раз встречаете юзер в строке // и записываем его в массив где ключ - это юзер $res[$key]['score'] = mb_substr_count($str, $key); $res[$key]['key'] = $key; } // сортируем массив по убыванию rsort($res); echo "Топ репостер - " . $res[0]['key'] . "\n"; echo "Он репостнул - " . $res[0]['score'] . "\n\n"; print_r($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 20
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/DHrDI
function name:  (null)
number of ops:  38
compiled vars:  !0 = $arr, !1 = $str, !2 = $res, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    7     1        INIT_FCALL                                               'implode'
          2        SEND_VAL                                                 '%7C'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   10     6        ASSIGN                                                   !2, <array>
   12     7      > FE_RESET_R                                       $8      !0, ->20
          8    > > FE_FETCH_R                                               $8, !3, ->20
   15     9    >   INIT_FCALL                                               'mb_substr_count'
         10        SEND_VAR                                                 !1
         11        SEND_VAR                                                 !3
         12        DO_ICALL                                         $11     
         13        FETCH_DIM_W                                      $9      !2, !3
         14        ASSIGN_DIM                                               $9, 'score'
         15        OP_DATA                                                  $11
   16    16        FETCH_DIM_W                                      $12     !2, !3
         17        ASSIGN_DIM                                               $12, 'key'
         18        OP_DATA                                                  !3
   12    19      > JMP                                                      ->8
         20    >   FE_FREE                                                  $8
   20    21        INIT_FCALL                                               'rsort'
         22        SEND_REF                                                 !2
         23        DO_ICALL                                                 
   22    24        FETCH_DIM_R                                      ~15     !2, 0
         25        FETCH_DIM_R                                      ~16     ~15, 'key'
         26        CONCAT                                           ~17     '%D0%A2%D0%BE%D0%BF+%D1%80%D0%B5%D0%BF%D0%BE%D1%81%D1%82%D0%B5%D1%80+-+', ~16
         27        CONCAT                                           ~18     ~17, '%0A'
         28        ECHO                                                     ~18
   23    29        FETCH_DIM_R                                      ~19     !2, 0
         30        FETCH_DIM_R                                      ~20     ~19, 'score'
         31        CONCAT                                           ~21     '%D0%9E%D0%BD+%D1%80%D0%B5%D0%BF%D0%BE%D1%81%D1%82%D0%BD%D1%83%D0%BB+-+', ~20
         32        CONCAT                                           ~22     ~21, '%0A%0A'
         33        ECHO                                                     ~22
   25    34        INIT_FCALL                                               'print_r'
         35        SEND_VAR                                                 !2
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.88 ms | 1401 KiB | 21 Q