3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Surprise surprise! When the 2nd array param of array_diff() contains an elemant with value false, // the result will no longer contain null values. function myIsset($value) { return isset($value); } $arrayWithTrueValue = array( 'null1' => null, 'null2' => null, 'bool' => true, ); $filteredArray = array_filter($arrayWithTrueValue, 'myIsset'); echo "\$arrayWithTrueValue has three elements..\n"; var_dump($arrayWithTrueValue); echo "\$filteredArray has one element (only isset(true) === true)\n"; var_dump($filteredArray); echo "so the difference is an array with two elements..\n"; var_dump(array_diff($arrayWithTrueValue, $filteredArray)); $arrayWithFalseValue = $arrayWithTrueValue; $arrayWithFalseValue['bool'] = false; $filteredArrayWithOnlyFalse = array_filter($arrayWithFalseValue, 'myIsset'); var_dump($arrayWithFalseValue, $filteredArrayWithOnlyFalse, array_diff($arrayWithFalseValue, $filteredArrayWithOnlyFalse));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LsH4L
function name:  (null)
number of ops:  40
compiled vars:  !0 = $arrayWithTrueValue, !1 = $filteredArray, !2 = $arrayWithFalseValue, !3 = $filteredArrayWithOnlyFalse
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, <array>
   17     1        INIT_FCALL                                               'array_filter'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'myIsset'
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   19     6        ECHO                                                     '%24arrayWithTrueValue+has+three+elements..%0A'
   20     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
   22    10        ECHO                                                     '%24filteredArray+has+one+element+%28only+isset%28true%29+%3D%3D%3D+true%29%0A'
   23    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
   25    14        ECHO                                                     'so+the+difference+is+an+array+with+two+elements..%0A'
   26    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'array_diff'
         17        SEND_VAR                                                 !0
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                                 
   28    22        ASSIGN                                                   !2, !0
   29    23        ASSIGN_DIM                                               !2, 'bool'
         24        OP_DATA                                                  <false>
   31    25        INIT_FCALL                                               'array_filter'
         26        SEND_VAR                                                 !2
         27        SEND_VAL                                                 'myIsset'
         28        DO_ICALL                                         $13     
         29        ASSIGN                                                   !3, $13
   33    30        INIT_FCALL                                               'var_dump'
         31        SEND_VAR                                                 !2
         32        SEND_VAR                                                 !3
         33        INIT_FCALL                                               'array_diff'
         34        SEND_VAR                                                 !2
         35        SEND_VAR                                                 !3
         36        DO_ICALL                                         $15     
         37        SEND_VAR                                                 $15
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Function myisset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LsH4L
function name:  myIsset
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        ISSET_ISEMPTY_CV                                 ~1      !0
          2      > RETURN                                                   ~1
    9     3*     > RETURN                                                   null

End of function myisset

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.67 ms | 1392 KiB | 19 Q