3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parse( $limiter = null ) { /** * Start parsing! */ $return_values = curl_multi_download( array( "users/" . userid, 'projects', 'comments/?o=-submit_date&page_size=5', 'tasks/?deadline=5', ), urlpath ); /** * End parsing! */ switch ( $limiter ) { case 'index': $return = array( 'projects' => $return_values['projects'], 'username' => $return_values['users/' . userid]['username'], 'calander_num' => '2', 'alerts_num' => '32', 'messages_num' => '123', '7_days_tasks_due' => '10' ); break; case 'dashboard': $return = array( 'username' => $return_values['users/' . userid]['username'], 'recent_comments' => $return_values['comments/?o=-submit_date&page_size=5'], 't_7_days' => day_counter($return_values['tasks/?deadline=5'], 7), 'projects' => $return_values['projects'] ); break; default: return null; break; } return $return; } function day_counter($array, $index) { $datearray = array(); foreach ($array['results'] as $key => &$value) { array_push($datearray , $array['results'][$key]['deadline']); } $datearray = array_count_values($datearray); for ($i = 0; $i < $index; $i++) { if (isset($datearray[date('Y-m-d', strtotime('+'.$i.' day', time()))])) { $return[$i] = $datearray[date('Y-m-d', strtotime('+'.$i.' day', time()))]; } else { $return[$i] = 0; } } return $return; } function curl_multi_download( array $urls, $urlpath, array $custom_options = array() ) { // make sure the rolling window isn't greater than the # of urls $rolling_window = 20; $rolling_window = ( sizeof( $urls ) < $rolling_window ) ? sizeof( $urls ) : $rolling_window; $master = curl_multi_init(); $curl_arr = array(); $options = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 5, ) + $custom_options; // start the first batch of requests for ( $i = 0; $i < $rolling_window; $i++ ) { $ch = curl_init(); $options[CURLOPT_URL] = $urlpath . $urls[$i]; curl_setopt_array( $ch, $options ); curl_multi_add_handle( $master, $ch ); } $return_values = array(); do { while ( ( $execrun = curl_multi_exec( $master, $running ) ) == CURLM_CALL_MULTI_PERFORM ); if ( $execrun != CURLM_OK ) break; // a request was just completed -- find out which one while ( $done = curl_multi_info_read( $master ) ) { $info = curl_getinfo( $done['handle'] ); // request successful. process output using the callback function. $output = curl_multi_getcontent( $done['handle'] ); // call_user_func_array($callback, array($info, $output)); if ( $info['http_code'] == '200' ) { //print_r(curl_getinfo($done['handle'])); //$return_values[curl_getinfo($done['handle'])['url']] = json_decode( $output, true ); $return_values[rtrim( substr( curl_getinfo($done['handle'])['url'], strlen ($urlpath) ), '/' )] = json_decode( $output, true ); } // var_dump($return_values); if ( isset( $urls[$i + 1] ) ) { // start a new request (it's important to do this before removing the old one) $ch = curl_init(); $options[CURLOPT_URL] = $urlpath . $urls[$i++]; // increment i curl_setopt_array( $ch, $options ); curl_multi_add_handle( $master, $ch ); } // remove the curl handle that just completed curl_multi_remove_handle( $master, $done['handle'] ); } } while ( $running ); curl_multi_close( $master ); return $return_values; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/83ToL
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  123     0  E > > RETURN                                                   1

Function parse:
Finding entry points
Branch analysis from position: 0
4 jumps found. (Code = 188) Position 1 = 19, Position 2 = 32, Position 3 = 50, Position 4 = 14
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 52
Branch analysis from position: 52
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 32
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
Branch analysis from position: 32
Branch analysis from position: 19
filename:       /in/83ToL
function name:  parse
number of ops:  54
compiled vars:  !0 = $limiter, !1 = $return_values, !2 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV_INIT                                        !0      null
    6     1        INIT_FCALL_BY_NAME                                       'curl_multi_download'
    7     2        FETCH_CONSTANT                                   ~3      'userid'
          3        CONCAT                                           ~4      'users%2F', ~3
          4        INIT_ARRAY                                       ~5      ~4
    8     5        ADD_ARRAY_ELEMENT                                ~5      'projects'
    9     6        ADD_ARRAY_ELEMENT                                ~5      'comments%2F%3Fo%3D-submit_date%26page_size%3D5'
   10     7        ADD_ARRAY_ELEMENT                                ~5      'tasks%2F%3Fdeadline%3D5'
          8        SEND_VAL_EX                                              ~5
   11     9        FETCH_CONSTANT                                   ~6      'urlpath'
         10        SEND_VAL_EX                                              ~6
         11        DO_FCALL                                      0  $7      
    6    12        ASSIGN                                                   !1, $7
   16    13      > SWITCH_STRING                                            !0, [ 'index':->19, 'dashboard':->32, ], ->50
   17    14    >   IS_EQUAL                                                 !0, 'index'
         15      > JMPNZ                                                    ~9, ->19
   27    16    >   IS_EQUAL                                                 !0, 'dashboard'
         17      > JMPNZ                                                    ~9, ->32
         18    > > JMP                                                      ->50
   18    19    >   FETCH_DIM_R                                      ~10     !1, 'projects'
         20        INIT_ARRAY                                       ~11     ~10, 'projects'
   19    21        FETCH_CONSTANT                                   ~12     'userid'
         22        CONCAT                                           ~13     'users%2F', ~12
         23        FETCH_DIM_R                                      ~14     !1, ~13
         24        FETCH_DIM_R                                      ~15     ~14, 'username'
         25        ADD_ARRAY_ELEMENT                                ~11     ~15, 'username'
   20    26        ADD_ARRAY_ELEMENT                                ~11     '2', 'calander_num'
   21    27        ADD_ARRAY_ELEMENT                                ~11     '32', 'alerts_num'
   22    28        ADD_ARRAY_ELEMENT                                ~11     '123', 'messages_num'
   23    29        ADD_ARRAY_ELEMENT                                ~11     '10', '7_days_tasks_due'
   18    30        ASSIGN                                                   !2, ~11
   25    31      > JMP                                                      ->52
   28    32    >   FETCH_CONSTANT                                   ~17     'userid'
         33        CONCAT                                           ~18     'users%2F', ~17
         34        FETCH_DIM_R                                      ~19     !1, ~18
         35        FETCH_DIM_R                                      ~20     ~19, 'username'
         36        INIT_ARRAY                                       ~21     ~20, 'username'
   29    37        FETCH_DIM_R                                      ~22     !1, 'comments%2F%3Fo%3D-submit_date%26page_size%3D5'
         38        ADD_ARRAY_ELEMENT                                ~21     ~22, 'recent_comments'
   30    39        INIT_FCALL_BY_NAME                                       'day_counter'
         40        CHECK_FUNC_ARG                                           
         41        FETCH_DIM_FUNC_ARG                               $23     !1, 'tasks%2F%3Fdeadline%3D5'
         42        SEND_FUNC_ARG                                            $23
         43        SEND_VAL_EX                                              7
         44        DO_FCALL                                      0  $24     
         45        ADD_ARRAY_ELEMENT                                ~21     $24, 't_7_days'
   31    46        FETCH_DIM_R                                      ~25     !1, 'projects'
         47        ADD_ARRAY_ELEMENT                                ~21     ~25, 'projects'
   28    48        ASSIGN                                                   !2, ~21
   33    49      > JMP                                                      ->52
   36    50    > > RETURN                                                   null
   37    51*       JMP                                                      ->52
   40    52    > > RETURN                                                   !2
   41    53*     > RETURN                                                   null

End of function parse

Function day_counter:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 126) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 22
Branch analysis from position: 57
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 52
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 54
Branch analysis from position: 54
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 22
Branch analysis from position: 57
Branch analysis from position: 22
Branch analysis from position: 52
2 jumps found. (Code = 44) Position 1 = 57, Position 2 = 22
Branch analysis from position: 57
Branch analysis from position: 22
Branch analysis from position: 15
filename:       /in/83ToL
function name:  day_counter
number of ops:  59
compiled vars:  !0 = $array, !1 = $index, !2 = $datearray, !3 = $value, !4 = $key, !5 = $i, !6 = $return
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   45     2        ASSIGN                                                   !2, <array>
   47     3        FETCH_DIM_W                                      $8      !0, 'results'
          4      > FE_RESET_RW                                      $9      $8, ->15
          5    > > FE_FETCH_RW                                      ~10     $9, !3, ->15
          6    >   ASSIGN                                                   !4, ~10
   48     7        INIT_FCALL                                               'array_push'
          8        SEND_REF                                                 !2
          9        FETCH_DIM_R                                      ~12     !0, 'results'
         10        FETCH_DIM_R                                      ~13     ~12, !4
         11        FETCH_DIM_R                                      ~14     ~13, 'deadline'
         12        SEND_VAL                                                 ~14
         13        DO_ICALL                                                 
   47    14      > JMP                                                      ->5
         15    >   FE_FREE                                                  $9
   51    16        INIT_FCALL                                               'array_count_values'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $16     
         19        ASSIGN                                                   !2, $16
   53    20        ASSIGN                                                   !5, 0
         21      > JMP                                                      ->55
   54    22    >   INIT_FCALL                                               'date'
         23        SEND_VAL                                                 'Y-m-d'
         24        INIT_FCALL                                               'strtotime'
         25        CONCAT                                           ~19     '%2B', !5
         26        CONCAT                                           ~20     ~19, '+day'
         27        SEND_VAL                                                 ~20
         28        INIT_FCALL                                               'time'
         29        DO_ICALL                                         $21     
         30        SEND_VAR                                                 $21
         31        DO_ICALL                                         $22     
         32        SEND_VAR                                                 $22
         33        DO_ICALL                                         $23     
         34        ISSET_ISEMPTY_DIM_OBJ                         0          !2, $23
         35      > JMPZ                                                     ~24, ->52
   55    36    >   INIT_FCALL                                               'date'
         37        SEND_VAL                                                 'Y-m-d'
         38        INIT_FCALL                                               'strtotime'
         39        CONCAT                                           ~26     '%2B', !5
         40        CONCAT                                           ~27     ~26, '+day'
         41        SEND_VAL                                                 ~27
         42        INIT_FCALL                                               'time'
         43        DO_ICALL                                         $28     
         44        SEND_VAR                                                 $28
         45        DO_ICALL                                         $29     
         46        SEND_VAR                                                 $29
         47        DO_ICALL                                         $30     
         48        FETCH_DIM_R                                      ~31     !2, $30
         49        ASSIGN_DIM                                               !6, !5
         50        OP_DATA                                                  ~31
         51      > JMP                                                      ->54
   57    52    >   ASSIGN_DIM                                               !6, !5
         53        OP_DATA                                                  0
   53    54    >   PRE_INC                                                  !5
         55    >   IS_SMALLER                                               !5, !1
         56      > JMPNZ                                                    ~34, ->22
   60    57    > > RETURN                                                   !6
   61    58*     > RETURN                                                   null

End of function day_counter

Function curl_multi_download:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 26
Branch analysis from position: 45
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 55, Position 2 = 47
Branch analysis from position: 55
2 jumps found. (Code = 43) Position 1 = 58, Position 2 = 59
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 128
Branch analysis from position: 128
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 122
Branch analysis from position: 122
2 jumps found. (Code = 44) Position 1 = 127, Position 2 = 60
Branch analysis from position: 127
2 jumps found. (Code = 44) Position 1 = 128, Position 2 = 46
Branch analysis from position: 128
Branch analysis from position: 46
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 75, Position 2 = 96
Branch analysis from position: 75
2 jumps found. (Code = 43) Position 1 = 99, Position 2 = 116
Branch analysis from position: 99
2 jumps found. (Code = 44) Position 1 = 127, Position 2 = 60
Branch analysis from position: 127
Branch analysis from position: 60
Branch analysis from position: 116
Branch analysis from position: 96
Branch analysis from position: 47
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 26
Branch analysis from position: 45
Branch analysis from position: 26
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
filename:       /in/83ToL
function name:  curl_multi_download
number of ops:  133
compiled vars:  !0 = $urls, !1 = $urlpath, !2 = $custom_options, !3 = $rolling_window, !4 = $master, !5 = $curl_arr, !6 = $options, !7 = $i, !8 = $ch, !9 = $return_values, !10 = $execrun, !11 = $running, !12 = $info, !13 = $done, !14 = $output
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   64     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      <array>
   67     3        ASSIGN                                                   !3, 20
   68     4        COUNT                                            ~16     !0
          5        IS_SMALLER                                               ~16, !3
          6      > JMPZ                                                     ~17, ->10
          7    >   COUNT                                            ~18     !0
          8        QM_ASSIGN                                        ~19     ~18
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~19     !3
         11    >   ASSIGN                                                   !3, ~19
   70    12        INIT_FCALL_BY_NAME                                       'curl_multi_init'
         13        DO_FCALL                                      0  $21     
         14        ASSIGN                                                   !4, $21
   71    15        ASSIGN                                                   !5, <array>
   73    16        FETCH_CONSTANT                                   ~24     'CURLOPT_RETURNTRANSFER'
         17        INIT_ARRAY                                       ~25     <true>, ~24
   74    18        FETCH_CONSTANT                                   ~26     'CURLOPT_FOLLOWLOCATION'
   73    19        ADD_ARRAY_ELEMENT                                ~25     <true>, ~26
   75    20        FETCH_CONSTANT                                   ~27     'CURLOPT_MAXREDIRS'
         21        ADD_ARRAY_ELEMENT                                ~25     5, ~27
   76    22        ADD                                              ~28     ~25, !2
   72    23        ASSIGN                                                   !6, ~28
   79    24        ASSIGN                                                   !7, 0
         25      > JMP                                                      ->43
   81    26    >   INIT_FCALL_BY_NAME                                       'curl_init'
         27        DO_FCALL                                      0  $31     
         28        ASSIGN                                                   !8, $31
   82    29        FETCH_CONSTANT                                   ~33     'CURLOPT_URL'
         30        FETCH_DIM_R                                      ~35     !0, !7
         31        CONCAT                                           ~36     !1, ~35
         32        ASSIGN_DIM                                               !6, ~33
         33        OP_DATA                                                  ~36
   83    34        INIT_FCALL_BY_NAME                                       'curl_setopt_array'
         35        SEND_VAR_EX                                              !8
         36        SEND_VAR_EX                                              !6
         37        DO_FCALL                                      0          
   84    38        INIT_FCALL_BY_NAME                                       'curl_multi_add_handle'
         39        SEND_VAR_EX                                              !4
         40        SEND_VAR_EX                                              !8
         41        DO_FCALL                                      0          
   79    42        PRE_INC                                                  !7
         43    >   IS_SMALLER                                               !7, !3
         44      > JMPNZ                                                    ~40, ->26
   86    45    >   ASSIGN                                                   !9, <array>
   89    46    > > JMP                                                      ->47
         47    >   INIT_FCALL_BY_NAME                                       'curl_multi_exec'
         48        SEND_VAR_EX                                              !4
         49        SEND_VAR_EX                                              !11
         50        DO_FCALL                                      0  $42     
         51        ASSIGN                                           ~43     !10, $42
         52        FETCH_CONSTANT                                   ~44     'CURLM_CALL_MULTI_PERFORM'
         53        IS_EQUAL                                                 ~43, ~44
         54      > JMPNZ                                                    ~45, ->47
   90    55    >   FETCH_CONSTANT                                   ~46     'CURLM_OK'
         56        IS_NOT_EQUAL                                             !10, ~46
         57      > JMPZ                                                     ~47, ->59
   91    58    > > JMP                                                      ->128
   93    59    > > JMP                                                      ->122
   95    60    >   INIT_FCALL_BY_NAME                                       'curl_getinfo'
         61        CHECK_FUNC_ARG                                           
         62        FETCH_DIM_FUNC_ARG                               $48     !13, 'handle'
         63        SEND_FUNC_ARG                                            $48
         64        DO_FCALL                                      0  $49     
         65        ASSIGN                                                   !12, $49
   98    66        INIT_FCALL_BY_NAME                                       'curl_multi_getcontent'
         67        CHECK_FUNC_ARG                                           
         68        FETCH_DIM_FUNC_ARG                               $51     !13, 'handle'
         69        SEND_FUNC_ARG                                            $51
         70        DO_FCALL                                      0  $52     
         71        ASSIGN                                                   !14, $52
  100    72        FETCH_DIM_R                                      ~54     !12, 'http_code'
         73        IS_EQUAL                                                 ~54, '200'
         74      > JMPZ                                                     ~55, ->96
  103    75    >   INIT_FCALL                                               'rtrim'
         76        INIT_FCALL                                               'substr'
         77        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         78        CHECK_FUNC_ARG                                           
         79        FETCH_DIM_FUNC_ARG                               $56     !13, 'handle'
         80        SEND_FUNC_ARG                                            $56
         81        DO_FCALL                                      0  $57     
         82        FETCH_DIM_R                                      ~58     $57, 'url'
         83        SEND_VAL                                                 ~58
         84        STRLEN                                           ~59     !1
         85        SEND_VAL                                                 ~59
         86        DO_ICALL                                         $60     
         87        SEND_VAR                                                 $60
         88        SEND_VAL                                                 '%2F'
         89        DO_ICALL                                         $61     
         90        INIT_FCALL                                               'json_decode'
         91        SEND_VAR                                                 !14
         92        SEND_VAL                                                 <true>
         93        DO_ICALL                                         $63     
         94        ASSIGN_DIM                                               !9, $61
         95        OP_DATA                                                  $63
  107    96    >   ADD                                              ~64     !7, 1
         97        ISSET_ISEMPTY_DIM_OBJ                         0          !0, ~64
         98      > JMPZ                                                     ~65, ->116
  110    99    >   INIT_FCALL_BY_NAME                                       'curl_init'
        100        DO_FCALL                                      0  $66     
        101        ASSIGN                                                   !8, $66
  111   102        FETCH_CONSTANT                                   ~68     'CURLOPT_URL'
        103        POST_INC                                         ~70     !7
        104        FETCH_DIM_R                                      ~71     !0, ~70
        105        CONCAT                                           ~72     !1, ~71
        106        ASSIGN_DIM                                               !6, ~68
        107        OP_DATA                                                  ~72
  112   108        INIT_FCALL_BY_NAME                                       'curl_setopt_array'
        109        SEND_VAR_EX                                              !8
        110        SEND_VAR_EX                                              !6
        111        DO_FCALL                                      0          
  113   112        INIT_FCALL_BY_NAME                                       'curl_multi_add_handle'
        113        SEND_VAR_EX                                              !4
        114        SEND_VAR_EX                                              !8
        115        DO_FCALL                                      0          
  117   116    >   INIT_FCALL_BY_NAME                                       'curl_multi_remove_handle'
        117        SEND_VAR_EX                                              !4
        118        CHECK_FUNC_ARG                                           
        119        FETCH_DIM_FUNC_ARG                               $75     !13, 'handle'
        120        SEND_FUNC_ARG                                            $75
        121        DO_FCALL                                      0          
   93   122    >   INIT_FCALL_BY_NAME                                       'curl_multi_info_read'
        123        SEND_VAR_EX                                              !4
        124        DO_FCALL                                      0  $77     
        125        ASSIGN                                           ~78     !13, $77
        126      > JMPNZ                                                    ~78, ->60
  119   127    > > JMPNZ                                                    !11, ->46
  121   128    >   INIT_FCALL_BY_NAME                                       'curl_multi_close'
        129        SEND_VAR_EX                                              !4
        130        DO_FCALL                                      0          
  122   131      > RETURN                                                   !9
  123   132*     > RETURN                                                   null

End of function curl_multi_download

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.26 ms | 1420 KiB | 29 Q