3v4l.org

run code in 500+ PHP versions simultaneously
<?php function niceAuthorsPrint(array $authors, $takeCount){ $totalAuthors = count( $authors ); $tailCount = $totalAuthors - $takeCount; $first = array_slice($authors, 0, $takeCount); $othersLabel = $tailCount == 1 ? 'other' : 'others'; $string = implode( ", ", $first ); if($tailCount > 0){ $string .= " and " . $tailCount . ' ' . $othersLabel; } return $string; } // take 3 echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 3) ."\n<br>"; // take 4 echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 4) ."\n<br>"; // take 5 echo niceAuthorsPrint(array( 'user1', 'user2', 'user3', 'user4', 'user5' ), 5) ."\n<br>"; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e76Id
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                                   'niceauthorsprint'
          1        SEND_VAL                                                     <array>
          2        SEND_VAL                                                     3
          3        DO_FCALL                                          0  $0      
          4        CONCAT                                               ~1      $0, '%0A%3Cbr%3E'
          5        ECHO                                                         ~1
   25     6        INIT_FCALL                                                   'niceauthorsprint'
          7        SEND_VAL                                                     <array>
          8        SEND_VAL                                                     4
          9        DO_FCALL                                          0  $2      
         10        CONCAT                                               ~3      $2, '%0A%3Cbr%3E'
         11        ECHO                                                         ~3
   28    12        INIT_FCALL                                                   'niceauthorsprint'
         13        SEND_VAL                                                     <array>
         14        SEND_VAL                                                     5
         15        DO_FCALL                                          0  $4      
         16        CONCAT                                               ~5      $4, '%0A%3Cbr%3E'
         17        ECHO                                                         ~5
   30    18      > RETURN                                                       1

Function niceauthorsprint:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
Branch analysis from position: 26
filename:       /in/e76Id
function name:  niceAuthorsPrint
number of ops:  28
compiled vars:  !0 = $authors, !1 = $takeCount, !2 = $totalAuthors, !3 = $tailCount, !4 = $first, !5 = $othersLabel, !6 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    5     2        COUNT                                                ~7      !0
          3        ASSIGN                                                       !2, ~7
    6     4        SUB                                                  ~9      !2, !1
          5        ASSIGN                                                       !3, ~9
    8     6        INIT_FCALL                                                   'array_slice'
          7        SEND_VAR                                                     !0
          8        SEND_VAL                                                     0
          9        SEND_VAR                                                     !1
         10        DO_ICALL                                             $11     
         11        ASSIGN                                                       !4, $11
   10    12        IS_EQUAL                                                     !3, 1
         13      > JMPZ                                                         ~13, ->16
         14    >   QM_ASSIGN                                            ~14     'other'
         15      > JMP                                                          ->17
         16    >   QM_ASSIGN                                            ~14     'others'
         17    >   ASSIGN                                                       !5, ~14
   12    18        FRAMELESS_ICALL_2                implode             ~16     '%2C+', !4
         19        ASSIGN                                                       !6, ~16
   14    20        IS_SMALLER                                                   0, !3
         21      > JMPZ                                                         ~18, ->26
   15    22    >   CONCAT                                               ~19     '+and+', !3
         23        CONCAT                                               ~20     ~19, '+'
         24        CONCAT                                               ~21     ~20, !5
         25        ASSIGN_OP                                         8          !6, ~21
   18    26    > > RETURN                                                       !6
   19    27*     > RETURN                                                       null

End of function niceauthorsprint

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
162.28 ms | 2571 KiB | 17 Q