3v4l.org

run code in 300+ PHP versions simultaneously
<?php $treadmills = [ 'bowflexseries3' => [ 'brand' => 'Bowflex', 'description' => 'Bowflex Series 3', 'image' => '/images/bowflex-series-3-150x150.jpg', 'discontinued' => '0' ], 'bowflexseries5' => [ 'brand' => 'Bowflex', 'description' => 'Bowflex Series 5', 'image' => '/images/bowflex-series-5-treadmill-review-150x150.jpg', 'discontinued' => '1' ], 'bowflextc10' => [ 'brand' => 'Bowflex', 'description' => 'Bowflex Treadclimber TC10', 'image' => '/images/bowflex-treadclimber-tc10-review-150x150.jpg', 'discontinued' => '0' ] ]; function randomTreadmill() { global $treadmills; // Filter out discontinued treadmills $filtered = array_filter($treadmills, function($treadmill) { return $treadmill['discontinued'] == 0; }); // Shuffle, and return the first one shuffle($filtered); return array_shift($filtered); } $treadmill = randomTreadmill(); echo $treadmill['brand'] . "\n"; echo $treadmill['description'] . "\n"; echo $treadmill['image'] . "\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mkcuK
function name:  (null)
number of ops:  14
compiled vars:  !0 = $treadmills, !1 = $treadmill
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   36     1        INIT_FCALL                                               'randomtreadmill'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   37     4        FETCH_DIM_R                                      ~5      !1, 'brand'
          5        CONCAT                                           ~6      ~5, '%0A'
          6        ECHO                                                     ~6
   38     7        FETCH_DIM_R                                      ~7      !1, 'description'
          8        CONCAT                                           ~8      ~7, '%0A'
          9        ECHO                                                     ~8
   39    10        FETCH_DIM_R                                      ~9      !1, 'image'
         11        CONCAT                                           ~10     ~9, '%0A'
         12        ECHO                                                     ~10
         13      > RETURN                                                   1

Function randomtreadmill:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mkcuK
function name:  randomTreadmill
number of ops:  15
compiled vars:  !0 = $treadmills, !1 = $filtered
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   BIND_GLOBAL                                              !0, 'treadmills'
   27     1        INIT_FCALL                                               'array_filter'
          2        SEND_VAR                                                 !0
          3        DECLARE_LAMBDA_FUNCTION                          ~2      [0]
   29     4        SEND_VAL                                                 ~2
   27     5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !1, $3
   32     7        INIT_FCALL                                               'shuffle'
          8        SEND_REF                                                 !1
          9        DO_ICALL                                                 
   33    10        INIT_FCALL                                               'array_shift'
         11        SEND_REF                                                 !1
         12        DO_ICALL                                         $6      
         13      > RETURN                                                   $6
   34    14*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mkcuK
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $treadmill
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   RECV                                             !0      
   28     1        FETCH_DIM_R                                      ~1      !0, 'discontinued'
          2        IS_EQUAL                                         ~2      ~1, 0
          3      > RETURN                                                   ~2
   29     4*     > RETURN                                                   null

End of Dynamic Function 0

End of function randomtreadmill

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.19 ms | 1020 KiB | 17 Q