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/MO7j4
function name:  (null)
number of ops:  44
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        NOP                                                      
          7        FAST_CONCAT                                      ~7      !0, '+has+three+elements..%0A'
          8        ECHO                                                     ~7
   20     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
   22    12        NOP                                                      
         13        FAST_CONCAT                                      ~9      !1, '+has+one+element+%28only+isset%28true%29+%3D%3D%3D+true%29%0A'
         14        ECHO                                                     ~9
   23    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                                 
   25    18        ECHO                                                     'so+the+difference+is+an+array+with+two+elements..%0A'
   26    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL                                               'array_diff'
         21        SEND_VAR                                                 !0
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                         $11     
         24        SEND_VAR                                                 $11
         25        DO_ICALL                                                 
   28    26        ASSIGN                                                   !2, !0
   29    27        ASSIGN_DIM                                               !2, 'bool'
         28        OP_DATA                                                  <false>
   31    29        INIT_FCALL                                               'array_filter'
         30        SEND_VAR                                                 !2
         31        SEND_VAL                                                 'myIsset'
         32        DO_ICALL                                         $15     
         33        ASSIGN                                                   !3, $15
   33    34        INIT_FCALL                                               'var_dump'
         35        SEND_VAR                                                 !2
         36        SEND_VAR                                                 !3
         37        INIT_FCALL                                               'array_diff'
         38        SEND_VAR                                                 !2
         39        SEND_VAR                                                 !3
         40        DO_ICALL                                         $17     
         41        SEND_VAR                                                 $17
         42        DO_ICALL                                                 
         43      > RETURN                                                   1

Function myisset:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MO7j4
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:
158.33 ms | 1403 KiB | 19 Q