3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr= [16,8,4,2,1]; $number = 13; $bin = str_split(str_pad(decbin($number),count($arr),"0",STR_PAD_LEFT)); Echo implode(",", array_intersect_key($arr,array_intersect($bin, ["1"])));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t9QQc
function name:  (null)
number of ops:  30
compiled vars:  !0 = $arr, !1 = $number, !2 = $bin
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    3     1        ASSIGN                                                   !1, 13
    4     2        INIT_FCALL                                               'str_split'
          3        INIT_FCALL                                               'str_pad'
          4        INIT_FCALL                                               'decbin'
          5        SEND_VAR                                                 !1
          6        DO_ICALL                                         $5      
          7        SEND_VAR                                                 $5
          8        COUNT                                            ~6      !0
          9        SEND_VAL                                                 ~6
         10        SEND_VAL                                                 '0'
         11        SEND_VAL                                                 0
         12        DO_ICALL                                         $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                         $8      
         15        ASSIGN                                                   !2, $8
    6    16        INIT_FCALL                                               'implode'
         17        SEND_VAL                                                 '%2C'
         18        INIT_FCALL                                               'array_intersect_key'
         19        SEND_VAR                                                 !0
         20        INIT_FCALL                                               'array_intersect'
         21        SEND_VAR                                                 !2
         22        SEND_VAL                                                 <array>
         23        DO_ICALL                                         $10     
         24        SEND_VAR                                                 $10
         25        DO_ICALL                                         $11     
         26        SEND_VAR                                                 $11
         27        DO_ICALL                                         $12     
         28        ECHO                                                     $12
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
130.75 ms | 1003 KiB | 19 Q