3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text ='{"success":true,"result":[{"product_id":"","faq_no":"FAQ1","faqcategories":"General","faqstatus":"Published","question":"\u062a\u0633\u062a \u062f\u0627\u0631\u061f","faq_answer":"\u0646\u062f\u0627\u0631\u062f","createdtime":"2017-11-20 08:35:47","modifiedtime":"2017-11-20 08:35:47","modifiedby":"19x1","source":"CRM","starred":"0","tags":"","id":"3x12"}]}'; function cleanjson($text){ $newjson = explode("{",$text); $newjsonrightclean="{".$newjson[1]."{".$newjson[2]; $newjson2 = explode("}}",$newjsonrightclean); if (!empty($newjson2)){ $out = $newjson2[0]."}}"; }else{ $newjson3 = explode("]}",$newjsonrightclean); $out = $newjson3[0]."]}"; } return $out; } echo $newjson2; echo cleanjson($text) ;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oYtVQ
function name:  (null)
number of ops:  7
compiled vars:  !0 = $text, !1 = $newjson2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%22success%22%3Atrue%2C%22result%22%3A%5B%7B%22product_id%22%3A%22%22%2C%22faq_no%22%3A%22FAQ1%22%2C%22faqcategories%22%3A%22General%22%2C%22faqstatus%22%3A%22Published%22%2C%22question%22%3A%22%5Cu062a%5Cu0633%5Cu062a+%5Cu062f%5Cu0627%5Cu0631%5Cu061f%22%2C%22faq_answer%22%3A%22%5Cu0646%5Cu062f%5Cu0627%5Cu0631%5Cu062f%22%2C%22createdtime%22%3A%222017-11-20+08%3A35%3A47%22%2C%22modifiedtime%22%3A%222017-11-20+08%3A35%3A47%22%2C%22modifiedby%22%3A%2219x1%22%2C%22source%22%3A%22CRM%22%2C%22starred%22%3A%220%22%2C%22tags%22%3A%22%22%2C%22id%22%3A%223x12%22%7D%5D%7D'
   19     1        ECHO                                                     !1
   20     2        INIT_FCALL                                               'cleanjson'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $3      
          5        ECHO                                                     $3
          6      > RETURN                                                   1

Function cleanjson:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oYtVQ
function name:  cleanjson
number of ops:  34
compiled vars:  !0 = $text, !1 = $newjson, !2 = $newjsonrightclean, !3 = $newjson2, !4 = $out, !5 = $newjson3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%7B'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !1, $6
    8     6        FETCH_DIM_R                                      ~8      !1, 1
          7        CONCAT                                           ~9      '%7B', ~8
          8        CONCAT                                           ~10     ~9, '%7B'
          9        FETCH_DIM_R                                      ~11     !1, 2
         10        CONCAT                                           ~12     ~10, ~11
         11        ASSIGN                                                   !2, ~12
    9    12        INIT_FCALL                                               'explode'
         13        SEND_VAL                                                 '%7D%7D'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                         $14     
         16        ASSIGN                                                   !3, $14
   10    17        ISSET_ISEMPTY_CV                                 ~16     !3
         18        BOOL_NOT                                         ~17     ~16
         19      > JMPZ                                                     ~17, ->24
   11    20    >   FETCH_DIM_R                                      ~18     !3, 0
         21        CONCAT                                           ~19     ~18, '%7D%7D'
         22        ASSIGN                                                   !4, ~19
         23      > JMP                                                      ->32
   13    24    >   INIT_FCALL                                               'explode'
         25        SEND_VAL                                                 '%5D%7D'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                         $21     
         28        ASSIGN                                                   !5, $21
   14    29        FETCH_DIM_R                                      ~23     !5, 0
         30        CONCAT                                           ~24     ~23, '%5D%7D'
         31        ASSIGN                                                   !4, ~24
   16    32    > > RETURN                                                   !4
   18    33*     > RETURN                                                   null

End of function cleanjson

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.7 ms | 1403 KiB | 16 Q