3v4l.org

run code in 300+ PHP versions simultaneously
<?php $recent_projects = [ [ 'project_title' => 'Project Name1', 'project_url' => 'url1' ], [ 'project_title' => 'Project Name2', 'project_url' => 'url2' ], [ 'project_title' => 'Project Name3', 'project_url' => 'url3' ], [ 'project_title' => 'Project Name4', 'project_url' => 'url4' ], [ 'project_title' => 'Project Name5', 'project_url' => 'url5' ] ]; $show_x_projects = 3; // How may projects to show $current_page = trim($_SERVER['REQUEST_URI'], '/'); // remove the project which matches with page url $filtered_projects = array_filter($recent_projects, function ($project) use ($current_page) { return ($project['project_url'] != $current_page); }); // select random 3 project from filtered projects $random_projects = array_rand($filtered_projects, $show_x_projects); foreach ($random_projects as $index) { $item = $filtered_projects[$index]; echo $item['project_title']."--"; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/6ATsH
function name:  (null)
number of ops:  31
compiled vars:  !0 = $recent_projects, !1 = $show_x_projects, !2 = $current_page, !3 = $filtered_projects, !4 = $random_projects, !5 = $index, !6 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   25     1        ASSIGN                                                   !1, 3
   26     2        INIT_FCALL                                               'trim'
          3        FETCH_R                      global              ~9      '_SERVER'
          4        FETCH_DIM_R                                      ~10     ~9, 'REQUEST_URI'
          5        SEND_VAL                                                 ~10
          6        SEND_VAL                                                 '%2F'
          7        DO_ICALL                                         $11     
          8        ASSIGN                                                   !2, $11
   29     9        INIT_FCALL                                               'array_filter'
         10        SEND_VAR                                                 !0
         11        DECLARE_LAMBDA_FUNCTION                          ~13     [0]
         12        BIND_LEXICAL                                             ~13, !2
   31    13        SEND_VAL                                                 ~13
   29    14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !3, $14
   34    16        INIT_FCALL                                               'array_rand'
         17        SEND_VAR                                                 !3
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $16     
         20        ASSIGN                                                   !4, $16
   36    21      > FE_RESET_R                                       $18     !4, ->29
         22    > > FE_FETCH_R                                               $18, !5, ->29
   37    23    >   FETCH_DIM_R                                      ~19     !3, !5
         24        ASSIGN                                                   !6, ~19
   39    25        FETCH_DIM_R                                      ~21     !6, 'project_title'
         26        CONCAT                                           ~22     ~21, '--'
         27        ECHO                                                     ~22
   36    28      > JMP                                                      ->22
         29    >   FE_FREE                                                  $18
   40    30      > 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/6ATsH
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $project, !1 = $current_page
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   30     2        FETCH_DIM_R                                      ~2      !0, 'project_url'
          3        IS_NOT_EQUAL                                     ~3      !1, ~2
          4      > RETURN                                                   ~3
   31     5*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.24 ms | 960 KiB | 16 Q