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'); var_dump($arrayWithTrueValue, $filteredArray, array_diff($arrayWithTrueValue, $filteredArray)); $arrayWithFalseValue = $arrayWithTrueValue; $arrayWithFalseValue['bool'] = false; $filteredArrayAlmostEmpty = array_filter($arrayWithFalseValue, 'myIsset'); var_dump($arrayWithFalseValue, $filteredArrayAlmostEmpty, array_diff($arrayWithFalseValue, $filteredArrayAlmostEmpty));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1WVGl
function name:  (null)
number of ops:  33
compiled vars:  !0 = $arrayWithTrueValue, !1 = $filteredArray, !2 = $arrayWithFalseValue, !3 = $filteredArrayAlmostEmpty
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        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        INIT_FCALL                                               'array_diff'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $7      
         13        SEND_VAR                                                 $7
         14        DO_ICALL                                                 
   21    15        ASSIGN                                                   !2, !0
   22    16        ASSIGN_DIM                                               !2, 'bool'
         17        OP_DATA                                                  <false>
   24    18        INIT_FCALL                                               'array_filter'
         19        SEND_VAR                                                 !2
         20        SEND_VAL                                                 'myIsset'
         21        DO_ICALL                                         $11     
         22        ASSIGN                                                   !3, $11
   26    23        INIT_FCALL                                               'var_dump'
         24        SEND_VAR                                                 !2
         25        SEND_VAR                                                 !3
         26        INIT_FCALL                                               'array_diff'
         27        SEND_VAR                                                 !2
         28        SEND_VAR                                                 !3
         29        DO_ICALL                                         $13     
         30        SEND_VAR                                                 $13
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

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