3v4l.org

run code in 300+ PHP versions simultaneously
<?php $files=[ 'Non-Images Only'=>'filename 1 (https://example.com/test.exe)', 'Mixed-Type'=>'filename 1 (https://example.com/test.pdf), filename 2 (https://example.com/cool_image.jpg), filename 3 (https://example.com/other-file.docx), filename 4 (https://example.com/nice_image.png)', 'Images-Only'=>'filename 1 (https://example.com/another.png), filename 2 (https://example.com/cool_image.jpg))']; foreach ($files as $type => $batch) { echo "Batch: ".$batch.PHP_EOL; echo "Expecting: ".$type.PHP_EOL; $images = preg_match('/\.(png|gif|jpe?g|bmp)/im', $batch); $nonImages = preg_match('/^(?!.*[.](png|gif|jpe?g|bmp))(?:.*$|,)/im', $batch); $result = ""; if ($images && $nonImages) { $result = "Mixed-Type"; } else { if ($images) { $result = "Images-Only"; } else { $result = "Non-Images Only"; } } echo "Result: ".$result.PHP_EOL; echo PHP_EOL; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 35
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 35
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 22, Position 2 = 23
Branch analysis from position: 22
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 23
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/0ZsQP
function name:  (null)
number of ops:  37
compiled vars:  !0 = $files, !1 = $batch, !2 = $type, !3 = $images, !4 = $nonImages, !5 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1      > FE_RESET_R                                       $7      !0, ->35
          2    > > FE_FETCH_R                                       ~8      $7, !1, ->35
          3    >   ASSIGN                                                   !2, ~8
   12     4        CONCAT                                           ~10     'Batch%3A+', !1
          5        CONCAT                                           ~11     ~10, '%0A'
          6        ECHO                                                     ~11
   13     7        CONCAT                                           ~12     'Expecting%3A+', !2
          8        CONCAT                                           ~13     ~12, '%0A'
          9        ECHO                                                     ~13
   14    10        INIT_FCALL                                               'preg_match'
         11        SEND_VAL                                                 '%2F%5C.%28png%7Cgif%7Cjpe%3Fg%7Cbmp%29%2Fim'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $14     
         14        ASSIGN                                                   !3, $14
   15    15        INIT_FCALL                                               'preg_match'
         16        SEND_VAL                                                 '%2F%5E%28%3F%21.%2A%5B.%5D%28png%7Cgif%7Cjpe%3Fg%7Cbmp%29%29%28%3F%3A.%2A%24%7C%2C%29%2Fim'
         17        SEND_VAR                                                 !1
         18        DO_ICALL                                         $16     
         19        ASSIGN                                                   !4, $16
   16    20        ASSIGN                                                   !5, ''
   17    21      > JMPZ_EX                                          ~19     !3, ->23
         22    >   BOOL                                             ~19     !4
         23    > > JMPZ                                                     ~19, ->26
   18    24    >   ASSIGN                                                   !5, 'Mixed-Type'
   17    25      > JMP                                                      ->30
   21    26    > > JMPZ                                                     !3, ->29
   22    27    >   ASSIGN                                                   !5, 'Images-Only'
   21    28      > JMP                                                      ->30
   25    29    >   ASSIGN                                                   !5, 'Non-Images+Only'
   28    30    >   CONCAT                                           ~23     'Result%3A+', !5
         31        CONCAT                                           ~24     ~23, '%0A'
         32        ECHO                                                     ~24
   29    33        ECHO                                                     '%0A'
   11    34      > JMP                                                      ->2
         35    >   FE_FREE                                                  $7
   30    36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.89 ms | 1015 KiB | 14 Q