3v4l.org

run code in 500+ 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 = 29
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 29
Branch analysis from position: 3
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 17
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/0ZsQP
function name:  (null)
number of ops:  31
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, ->29
          2    > > FE_FETCH_R                                           ~8      $7, !1, ->29
          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        FRAMELESS_ICALL_2                preg_match          ~14     '%2F%5C.%28png%7Cgif%7Cjpe%3Fg%7Cbmp%29%2Fim', !1
         11        ASSIGN                                                       !3, ~14
   15    12        FRAMELESS_ICALL_2                preg_match          ~16     '%2F%5E%28%3F%21.%2A%5B.%5D%28png%7Cgif%7Cjpe%3Fg%7Cbmp%29%29%28%3F%3A.%2A%24%7C%2C%29%2Fim', !1
         13        ASSIGN                                                       !4, ~16
   16    14        ASSIGN                                                       !5, ''
   17    15      > JMPZ_EX                                              ~19     !3, ->17
         16    >   BOOL                                                 ~19     !4
         17    > > JMPZ                                                         ~19, ->20
   18    18    >   ASSIGN                                                       !5, 'Mixed-Type'
   17    19      > JMP                                                          ->24
   21    20    > > JMPZ                                                         !3, ->23
   22    21    >   ASSIGN                                                       !5, 'Images-Only'
   21    22      > JMP                                                          ->24
   25    23    >   ASSIGN                                                       !5, 'Non-Images+Only'
   28    24    >   CONCAT                                               ~23     'Result%3A+', !5
         25        CONCAT                                               ~24     ~23, '%0A'
         26        ECHO                                                         ~24
   29    27        ECHO                                                         '%0A'
   11    28      > JMP                                                          ->2
         29    >   FE_FREE                                                      $7
   30    30      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
159.77 ms | 2695 KiB | 13 Q