3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ['kalem', ['elma', 'armut'], 'silgi', 'defter', 'kitap', 'çanta']; if (in_array('kalem', $arr)) echo 'Kalem var'.PHP_EOL; if (in_array(['elma', 'armut'], $arr)) echo 'içinde sadece elma ve armut olan bir dizi var'. PHP_EOL; if (in_array(['silgi', 'defter'], $arr)) echo 'Burası çalışmayacak'; else echo 'Bu fonksiyon dizi içerisindeki elemanları bu şekilde ayrı ayrı kontrol etmez!'. PHP_EOL; #Biz kendimiz yazalım, AYNI ANDA bir array içindeki değerleri kontrol etsin function in_array_(array $search, array $array): bool { foreach ($search as $item): if (!in_array($item, $array)) return false; endforeach; return true; } $search = ['kitap', 'çanta']; if (in_array_($search, $arr)) echo 'Aranan değerler dizide mecvut'. PHP_EOL; $search = ['kitap', 'çanta', ['elma', 'armut']]; if (in_array_($search, $arr)) echo 'Aranan değerler dizide mecvut. Array içinde array de arayabiliriz'. PHP_EOL; $search = ['kitap', 'çanta', 'masa']; if (in_array_($search, $arr)) echo 'Burası çalışmayacak'. PHP_EOL; else echo 'Aranan elemanlardan bir tanesi bile dizide yoksa sonuç FALSE döner';
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 13
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 28
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 35
Branch analysis from position: 34
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
Branch analysis from position: 28
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 28
Branch analysis from position: 27
Branch analysis from position: 28
Branch analysis from position: 13
Branch analysis from position: 7
filename:       /in/UkVvY
function name:  (null)
number of ops:  45
compiled vars:  !0 = $arr, !1 = $search
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        INIT_FCALL                                               'in_array'
          2        SEND_VAL                                                 'kalem'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5      > JMPZ                                                     $3, ->7
    6     6    >   ECHO                                                     'Kalem+var%0A'
    8     7    >   INIT_FCALL                                               'in_array'
          8        SEND_VAL                                                 <array>
          9        SEND_VAR                                                 !0
         10        DO_ICALL                                         $4      
         11      > JMPZ                                                     $4, ->13
    9    12    >   ECHO                                                     'i%C3%A7inde+sadece+elma+ve+armut+olan+bir+dizi+var%0A'
   11    13    >   INIT_FCALL                                               'in_array'
         14        SEND_VAL                                                 <array>
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $5      
         17      > JMPZ                                                     $5, ->20
   12    18    >   ECHO                                                     'Buras%C4%B1+%C3%A7al%C4%B1%C5%9Fmayacak'
   11    19      > JMP                                                      ->21
   14    20    >   ECHO                                                     'Bu+fonksiyon+dizi+i%C3%A7erisindeki+elemanlar%C4%B1+bu+%C5%9Fekilde+ayr%C4%B1+ayr%C4%B1+kontrol+etmez%21%0A'
   28    21    >   ASSIGN                                                   !1, <array>
   29    22        INIT_FCALL                                               'in_array_'
         23        SEND_VAR                                                 !1
         24        SEND_VAR                                                 !0
         25        DO_FCALL                                      0  $7      
         26      > JMPZ                                                     $7, ->28
   30    27    >   ECHO                                                     'Aranan+de%C4%9Ferler+dizide+mecvut%0A'
   32    28    >   ASSIGN                                                   !1, <array>
   33    29        INIT_FCALL                                               'in_array_'
         30        SEND_VAR                                                 !1
         31        SEND_VAR                                                 !0
         32        DO_FCALL                                      0  $9      
         33      > JMPZ                                                     $9, ->35
   34    34    >   ECHO                                                     'Aranan+de%C4%9Ferler+dizide+mecvut.+Array+i%C3%A7inde+array+de+arayabiliriz%0A'
   36    35    >   ASSIGN                                                   !1, <array>
   37    36        INIT_FCALL                                               'in_array_'
         37        SEND_VAR                                                 !1
         38        SEND_VAR                                                 !0
         39        DO_FCALL                                      0  $11     
         40      > JMPZ                                                     $11, ->43
   38    41    >   ECHO                                                     'Buras%C4%B1+%C3%A7al%C4%B1%C5%9Fmayacak%0A'
   37    42      > JMP                                                      ->44
   40    43    >   ECHO                                                     'Aranan+elemanlardan+bir+tanesi+bile+dizide+yoksa+sonu%C3%A7+FALSE+d%C3%B6ner'
         44    > > RETURN                                                   1

Function in_array_:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 13
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 13
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
filename:       /in/UkVvY
function name:  in_array_
number of ops:  17
compiled vars:  !0 = $search, !1 = $array, !2 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   20     2      > FE_RESET_R                                       $3      !0, ->13
          3    > > FE_FETCH_R                                               $3, !2, ->13
   22     4    >   INIT_FCALL                                               'in_array'
          5        SEND_VAR                                                 !2
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $4      
          8        BOOL_NOT                                         ~5      $4
          9      > JMPZ                                                     ~5, ->12
   23    10    >   FE_FREE                                                  $3
         11      > RETURN                                                   <false>
   20    12    > > JMP                                                      ->3
         13    >   FE_FREE                                                  $3
   25    14      > RETURN                                                   <true>
   26    15*       VERIFY_RETURN_TYPE                                       
         16*     > RETURN                                                   null

End of function in_array_

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
127.62 ms | 1452 KiB | 17 Q