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 ); } 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/sUpo5
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/sUpo5
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/sUpo5
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 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 54, Position 2 = 46
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 58
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 127
Branch analysis from position: 127
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 121
Branch analysis from position: 121
2 jumps found. (Code = 44) Position 1 = 126, Position 2 = 59
Branch analysis from position: 126
2 jumps found. (Code = 44) Position 1 = 127, Position 2 = 45
Branch analysis from position: 127
Branch analysis from position: 45
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 95
Branch analysis from position: 74
2 jumps found. (Code = 43) Position 1 = 98, Position 2 = 115
Branch analysis from position: 98
2 jumps found. (Code = 44) Position 1 = 126, Position 2 = 59
Branch analysis from position: 126
Branch analysis from position: 59
Branch analysis from position: 115
Branch analysis from position: 95
Branch analysis from position: 46
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/sUpo5
function name:  curl_multi_download
number of ops:  132
compiled vars:  !0 = $urls, !1 = $urlpath, !2 = $custom_options, !3 = $rolling_window, !4 = $master, !5 = $curl_arr, !6 = $options, !7 = $i, !8 = $ch, !9 = $execrun, !10 = $running, !11 = $info, !12 = $done, !13 = $output, !14 = $return_values
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
   89    45    > > JMP                                                      ->46
         46    >   INIT_FCALL_BY_NAME                                       'curl_multi_exec'
         47        SEND_VAR_EX                                              !4
         48        SEND_VAR_EX                                              !10
         49        DO_FCALL                                      0  $41     
         50        ASSIGN                                           ~42     !9, $41
         51        FETCH_CONSTANT                                   ~43     'CURLM_CALL_MULTI_PERFORM'
         52        IS_EQUAL                                                 ~42, ~43
         53      > JMPNZ                                                    ~44, ->46
   90    54    >   FETCH_CONSTANT                                   ~45     'CURLM_OK'
         55        IS_NOT_EQUAL                                             !9, ~45
         56      > JMPZ                                                     ~46, ->58
   91    57    > > JMP                                                      ->127
   93    58    > > JMP                                                      ->121
   95    59    >   INIT_FCALL_BY_NAME                                       'curl_getinfo'
         60        CHECK_FUNC_ARG                                           
         61        FETCH_DIM_FUNC_ARG                               $47     !12, 'handle'
         62        SEND_FUNC_ARG                                            $47
         63        DO_FCALL                                      0  $48     
         64        ASSIGN                                                   !11, $48
   98    65        INIT_FCALL_BY_NAME                                       'curl_multi_getcontent'
         66        CHECK_FUNC_ARG                                           
         67        FETCH_DIM_FUNC_ARG                               $50     !12, 'handle'
         68        SEND_FUNC_ARG                                            $50
         69        DO_FCALL                                      0  $51     
         70        ASSIGN                                                   !13, $51
  100    71        FETCH_DIM_R                                      ~53     !11, 'http_code'
         72        IS_EQUAL                                                 ~53, '200'
         73      > JMPZ                                                     ~54, ->95
  103    74    >   INIT_FCALL                                               'rtrim'
         75        INIT_FCALL                                               'substr'
         76        INIT_FCALL_BY_NAME                                       'curl_getinfo'
         77        CHECK_FUNC_ARG                                           
         78        FETCH_DIM_FUNC_ARG                               $55     !12, 'handle'
         79        SEND_FUNC_ARG                                            $55
         80        DO_FCALL                                      0  $56     
         81        FETCH_DIM_R                                      ~57     $56, 'url'
         82        SEND_VAL                                                 ~57
         83        STRLEN                                           ~58     !1
         84        SEND_VAL                                                 ~58
         85        DO_ICALL                                         $59     
         86        SEND_VAR                                                 $59
         87        SEND_VAL                                                 '%2F'
         88        DO_ICALL                                         $60     
         89        INIT_FCALL                                               'json_decode'
         90        SEND_VAR                                                 !13
         91        SEND_VAL                                                 <true>
         92        DO_ICALL                                         $62     
         93        ASSIGN_DIM                                               !14, $60
         94        OP_DATA                                                  $62
  107    95    >   ADD                                              ~63     !7, 1
         96        ISSET_ISEMPTY_DIM_OBJ                         0          !0, ~63
         97      > JMPZ                                                     ~64, ->115
  110    98    >   INIT_FCALL_BY_NAME                                       'curl_init'
         99        DO_FCALL                                      0  $65     
        100        ASSIGN                                                   !8, $65
  111   101        FETCH_CONSTANT                                   ~67     'CURLOPT_URL'
        102        POST_INC                                         ~69     !7
        103        FETCH_DIM_R                                      ~70     !0, ~69
        104        CONCAT                                           ~71     !1, ~70
        105        ASSIGN_DIM                                               !6, ~67
        106        OP_DATA                                                  ~71
  112   107        INIT_FCALL_BY_NAME                                       'curl_setopt_array'
        108        SEND_VAR_EX                                              !8
        109        SEND_VAR_EX                                              !6
        110        DO_FCALL                                      0          
  113   111        INIT_FCALL_BY_NAME                                       'curl_multi_add_handle'
        112        SEND_VAR_EX                                              !4
        113        SEND_VAR_EX                                              !8
        114        DO_FCALL                                      0          
  117   115    >   INIT_FCALL_BY_NAME                                       'curl_multi_remove_handle'
        116        SEND_VAR_EX                                              !4
        117        CHECK_FUNC_ARG                                           
        118        FETCH_DIM_FUNC_ARG                               $74     !12, 'handle'
        119        SEND_FUNC_ARG                                            $74
        120        DO_FCALL                                      0          
   93   121    >   INIT_FCALL_BY_NAME                                       'curl_multi_info_read'
        122        SEND_VAR_EX                                              !4
        123        DO_FCALL                                      0  $76     
        124        ASSIGN                                           ~77     !12, $76
        125      > JMPNZ                                                    ~77, ->59
  119   126    > > JMPNZ                                                    !10, ->45
  121   127    >   INIT_FCALL_BY_NAME                                       'curl_multi_close'
        128        SEND_VAR_EX                                              !4
        129        DO_FCALL                                      0          
  122   130      > RETURN                                                   !14
  123   131*     > RETURN                                                   null

End of function curl_multi_download

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.1 ms | 1420 KiB | 29 Q