3v4l.org

run code in 500+ PHP versions simultaneously
<?php $corrupted_byte_counts = <<<STRING a:12:{i:0;s:3:"three";i:1;s:5:"five";i:2;s:2:"newline1 newline2";i:3;s:6:"garçon";i:4;s:111:"double " quote \"escaped";i:5;s:1:"a,comma";i:6;s:9:"a:colon";i:7;s:0:"single 'quote";i:8;s:999:"semi;colon";s:5:"assoc";s:3:"yes";i:9;s:1:"monkey";wrenching doublequote-semicolon";s:3:"s:";s:9:"val s: val";} STRING; $repaired = preg_replace_callback( '/s:\d+:"(.*?)";(?=$|}|[si]:)/s', // ^^^^^^^^^^^^^^^^^^^-- this extension goes a little further to address a possible monkeywrench function ($m) { return 's:' . strlen($m[1]) . ":\"{$m[1]}\";"; }, $corrupted_byte_counts ); echo "corrupted serialized array:\n$corrupted_byte_counts"; echo "\n---\n"; echo "repaired serialized array:\n$repaired"; echo "\n---\n"; print_r(unserialize($repaired));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SApBV
function name:  (null)
number of ops:  23
compiled vars:  !0 = $corrupted_byte_counts, !1 = $repaired
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, 'a%3A12%3A%7Bi%3A0%3Bs%3A3%3A%22three%22%3Bi%3A1%3Bs%3A5%3A%22five%22%3Bi%3A2%3Bs%3A2%3A%22newline1%0Anewline2%22%3Bi%3A3%3Bs%3A6%3A%22gar%C3%A7on%22%3Bi%3A4%3Bs%3A111%3A%22double+%22+quote+%5C%22escaped%22%3Bi%3A5%3Bs%3A1%3A%22a%2Ccomma%22%3Bi%3A6%3Bs%3A9%3A%22a%3Acolon%22%3Bi%3A7%3Bs%3A0%3A%22single+%27quote%22%3Bi%3A8%3Bs%3A999%3A%22semi%3Bcolon%22%3Bs%3A5%3A%22assoc%22%3Bs%3A3%3A%22yes%22%3Bi%3A9%3Bs%3A1%3A%22monkey%22%3Bwrenching+doublequote-semicolon%22%3Bs%3A3%3A%22s%3A%22%3Bs%3A9%3A%22val+s%3A+val%22%3B%7D'
    7     1        INIT_FCALL                                                   'preg_replace_callback'
    8     2        SEND_VAL                                                     '%2Fs%3A%5Cd%2B%3A%22%28.%2A%3F%29%22%3B%28%3F%3D%24%7C%7D%7C%5Bsi%5D%3A%29%2Fs'
   10     3        DECLARE_LAMBDA_FUNCTION                              ~3      [0]
   12     4        SEND_VAL                                                     ~3
   13     5        SEND_VAR                                                     !0
    7     6        DO_ICALL                                             $4      
          7        ASSIGN                                                       !1, $4
   16     8        NOP                                                          
          9        FAST_CONCAT                                          ~6      'corrupted+serialized+array%3A%0A', !0
         10        ECHO                                                         ~6
   17    11        ECHO                                                         '%0A---%0A'
   18    12        NOP                                                          
         13        FAST_CONCAT                                          ~7      'repaired+serialized+array%3A%0A', !1
         14        ECHO                                                         ~7
   19    15        ECHO                                                         '%0A---%0A'
   20    16        INIT_FCALL                                                   'print_r'
         17        INIT_FCALL                                                   'unserialize'
         18        SEND_VAR                                                     !1
         19        DO_ICALL                                             $8      
         20        SEND_VAR                                                     $8
         21        DO_ICALL                                                     
         22      > 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/SApBV
function name:  {closure:/in/SApBV:10}
number of ops:  11
compiled vars:  !0 = $m
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   10     0  E >   RECV                                                 !0      
   11     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
   12    10*     > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
221.13 ms | 2561 KiB | 16 Q