3v4l.org

run code in 500+ PHP versions simultaneously
<?php $corrupted_byte_counts = <<<STRING s:151:"a:1:{i:0;a:4:{s:4:"name";s:15:"Chloe O'Gorman";s:6:"gender";s:6:"female";s:3:"age";s:3:"3_6";s:7:"present";s:34:"Something from Frozen or a jigsaw ";}}"; STRING; $repaired = preg_replace_callback( '/s:\d+:"(.*?)";/s', function ($m) { return 's:' . strlen($m[1]) . ":\"{$m[1]}\";"; }, unserialize($corrupted_byte_counts) // first unserialize string before repairing ); echo "corrupted serialized array:\n$corrupted_byte_counts"; echo "\n---\n"; echo "repaired serialized array:\n$repaired"; echo "\n---\n"; print_r(unserialize($repaired)); // unserialize repaired string echo "\n---\n"; echo serialize($repaired);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gHgUP
function name:  (null)
number of ops:  31
compiled vars:  !0 = $corrupted_byte_counts, !1 = $repaired
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, 's%3A151%3A%22a%3A1%3A%7Bi%3A0%3Ba%3A4%3A%7Bs%3A4%3A%22name%22%3Bs%3A15%3A%22Chloe+O%27Gorman%22%3Bs%3A6%3A%22gender%22%3Bs%3A6%3A%22female%22%3Bs%3A3%3A%22age%22%3Bs%3A3%3A%223_6%22%3Bs%3A7%3A%22present%22%3Bs%3A34%3A%22Something+from+Frozen+or+a+jigsaw+%22%3B%7D%7D%22%3B'
    6     1        INIT_FCALL                                                   'preg_replace_callback'
    7     2        SEND_VAL                                                     '%2Fs%3A%5Cd%2B%3A%22%28.%2A%3F%29%22%3B%2Fs'
    8     3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
   10     4        SEND_VAL                                                     ~3
   11     5        INIT_FCALL                                                   'unserialize'
          6        SEND_VAR                                                     !0
          7        DO_ICALL                                             $4      
          8        SEND_VAR                                                     $4
    6     9        DO_ICALL                                             $5      
         10        ASSIGN                                                       !1, $5
   14    11        NOP                                                          
         12        FAST_CONCAT                                          ~7      'corrupted+serialized+array%3A%0A', !0
         13        ECHO                                                         ~7
   15    14        ECHO                                                         '%0A---%0A'
   16    15        NOP                                                          
         16        FAST_CONCAT                                          ~8      'repaired+serialized+array%3A%0A', !1
         17        ECHO                                                         ~8
   17    18        ECHO                                                         '%0A---%0A'
   18    19        INIT_FCALL                                                   'print_r'
         20        INIT_FCALL                                                   'unserialize'
         21        SEND_VAR                                                     !1
         22        DO_ICALL                                             $9      
         23        SEND_VAR                                                     $9
         24        DO_ICALL                                                     
   19    25        ECHO                                                         '%0A---%0A'
   20    26        INIT_FCALL                                                   'serialize'
         27        SEND_VAR                                                     !1
         28        DO_ICALL                                             $11     
         29        ECHO                                                         $11
         30      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gHgUP
function name:  {closure:/in/gHgUP:8}
number of ops:  11
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
    9     1        FETCH_DIM_R                                          ~1      !0, 1
          2        STRLEN                                               ~2      ~1
          3        CONCAT                                               ~3      's%3A', ~2
          4        ROPE_INIT                                         3  ~6      '%3A%22'
          5        FETCH_DIM_R                                          ~4      !0, 1
          6        ROPE_ADD                                          1  ~6      ~6, ~4
          7        ROPE_END                                          2  ~5      ~6, '%22%3B'
          8        CONCAT                                               ~8      ~3, ~5
          9      > RETURN                                                       ~8
   10    10*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
171.67 ms | 2490 KiB | 17 Q