3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* * This code should loop through $data, converting null to 0. * * If it finds an array inside the data, it loops through that * converting null values to 0. * * The error'ed line throws the following PHP error which breaks the code: * ------- * PHP Warning: Cannot use a scalar value as an array * ------- */ $data = json_decode('{"last":"0.692776960","high":"0.692776960","low":"0.692776960","avg":0.6928,"vol":"0.252273837","vols":{"bid":null,"ask":null}}', true); $new_data = array_replace_recursive($data, function ($value) { if ($value === null) { return 0; } }); var_dump($new_data);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DCp6N
function name:  (null)
number of ops:  15
compiled vars:  !0 = $data, !1 = $new_data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%7B%22last%22%3A%220.692776960%22%2C%22high%22%3A%220.692776960%22%2C%22low%22%3A%220.692776960%22%2C%22avg%22%3A0.6928%2C%22vol%22%3A%220.252273837%22%2C%22vols%22%3A%7B%22bid%22%3Anull%2C%22ask%22%3Anull%7D%7D'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   14     5        INIT_FCALL                                               'array_replace_recursive'
          6        SEND_VAR                                                 !0
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FDCp6N%3A14%240'
   18     8        SEND_VAL                                                 ~4
          9        DO_ICALL                                         $5      
   14    10        ASSIGN                                                   !1, $5
   19    11        INIT_FCALL                                               'var_dump'
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FDCp6N%3A14%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DCp6N
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~1, ->4
   16     3    > > RETURN                                                   0
   18     4    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FDCp6N%3A14%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.49 ms | 1395 KiB | 19 Q