3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strData = <<<STR { "xData": ["2004-04", "2004-04", "2004-04", "2004-04", "2004-04", "2004-04", "2004-04", "2004-04", "2004-04", "2004-04", "2004-04", "2005-05", "2007-11"] } { "name": "Female", "data": [0.915, 0.239, 0.1944, 0.688, 0.8483, 0.0466, 0.3326, 0.6736, 0.0361, 0.4999, 0.8163, -0.3561, 1.1272, 0.5887, -0.1083, 0.713, -0.3287, 0.377, -0.0028, 0.6898, 0.734, 0.3036, -0.1518, 0.4427, 0.4422, 0.308, 0.7586, -0.1638, 0.6759, 0.4066, 0.1616, 0.6232, -0.8194, 0.2482, -0.2033, 0.2565, 0.3171, -0.0436, 0.2752, 0.4565, 0.5665, 0.4314, 0.4077, 0.4002, 0.9626, 0.9249] } { "name": "Male", "data": [0.1418, 1.2012, 0.3303, 0.2868, 0.3277, 0.2204, 0.6071, 0.4635, 0.7447, 0.3744, 0.3539, 0.9404, 0.897, 0.1206, 0.2797, 0.7477, 0.2737, 0.8536, 0.924, 1.0244, 0.0613, -0.3384, 0.6353, -0.5389, 0.773, 0.7062, 0.174, 0.2941, 0.9353, 0.7985, 1.4301, 0.2805, 0.9922, 0.9169, 0.6853, 0.4048, 0.0789, 0.4576, 1.0924, 0.8866, 0.3695, -0.1778, 0.4321, 0.4068, 0.8123, 0.9536, 0.4083, 0.6146, 0.088, 0.4721, 0.4143, 0.4272, 0.7681, -0.1504] } STR; $jsons = preg_split('#(?<=})\s*?(?={)#', $strData); $data = array_map(function($json){return json_decode($json, true);}, $jsons); $res = array_shift($data); $res['datasets'] = array_map(function($person){ $person['type'] = 'line'; return $person; }, $data); echo json_encode($res);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fbtuM
function name:  (null)
number of ops:  28
compiled vars:  !0 = $strData, !1 = $jsons, !2 = $data, !3 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7B%0A++++%22xData%22%3A+%5B%222004-04%22%2C+%222004-04%22%2C+%222004-04%22%2C+%222004-04%22%2C+%222004-04%22%2C+%222004-04%22%2C+%222004-04%22%2C+%222004-04%22%2C+%222004-04%22%2C+%222004-04%22%2C+%222004-04%22%2C+%222005-05%22%2C+%222007-11%22%5D%0A%7D+%7B%0A++++%22name%22%3A+%22Female%22%2C%0A++++%22data%22%3A+%5B0.915%2C+0.239%2C+0.1944%2C+0.688%2C+0.8483%2C+0.0466%2C+0.3326%2C+0.6736%2C+0.0361%2C+0.4999%2C+0.8163%2C+-0.3561%2C+1.1272%2C+0.5887%2C+-0.1083%2C+0.713%2C+-0.3287%2C+0.377%2C+-0.0028%2C+0.6898%2C+0.734%2C+0.3036%2C+-0.1518%2C+0.4427%2C+0.4422%2C+0.308%2C+0.7586%2C+-0.1638%2C+0.6759%2C+0.4066%2C+0.1616%2C+0.6232%2C+-0.8194%2C+0.2482%2C+-0.2033%2C+0.2565%2C+0.3171%2C+-0.0436%2C+0.2752%2C+0.4565%2C+0.5665%2C+0.4314%2C+0.4077%2C+0.4002%2C+0.9626%2C+0.9249%5D%0A%7D+%7B%0A++++%22name%22%3A+%22Male%22%2C%0A++++%22data%22%3A+%5B0.1418%2C+1.2012%2C+0.3303%2C+0.2868%2C+0.3277%2C+0.2204%2C+0.6071%2C+0.4635%2C+0.7447%2C+0.3744%2C+0.3539%2C+0.9404%2C+0.897%2C+0.1206%2C+0.2797%2C+0.7477%2C+0.2737%2C+0.8536%2C+0.924%2C+1.0244%2C+0.0613%2C+-0.3384%2C+0.6353%2C+-0.5389%2C+0.773%2C+0.7062%2C+0.174%2C+0.2941%2C+0.9353%2C+0.7985%2C+1.4301%2C+0.2805%2C+0.9922%2C+0.9169%2C+0.6853%2C+0.4048%2C+0.0789%2C+0.4576%2C+1.0924%2C+0.8866%2C+0.3695%2C+-0.1778%2C+0.4321%2C+0.4068%2C+0.8123%2C+0.9536%2C+0.4083%2C+0.6146%2C+0.088%2C+0.4721%2C+0.4143%2C+0.4272%2C+0.7681%2C+-0.1504%5D%0A%7D'
   15     1        INIT_FCALL                                               'preg_split'
          2        SEND_VAL                                                 '%23%28%3F%3C%3D%7D%29%5Cs%2A%3F%28%3F%3D%7B%29%23'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
   16     6        INIT_FCALL                                               'array_map'
          7        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          8        SEND_VAL                                                 ~7
          9        SEND_VAR                                                 !1
         10        DO_ICALL                                         $8      
         11        ASSIGN                                                   !2, $8
   18    12        INIT_FCALL                                               'array_shift'
         13        SEND_REF                                                 !2
         14        DO_ICALL                                         $10     
         15        ASSIGN                                                   !3, $10
   19    16        INIT_FCALL                                               'array_map'
         17        DECLARE_LAMBDA_FUNCTION                          ~13     [1]
   22    18        SEND_VAL                                                 ~13
         19        SEND_VAR                                                 !2
   19    20        DO_ICALL                                         $14     
         21        ASSIGN_DIM                                               !3, 'datasets'
   22    22        OP_DATA                                                  $14
   24    23        INIT_FCALL                                               'json_encode'
         24        SEND_VAR                                                 !3
         25        DO_ICALL                                         $15     
         26        ECHO                                                     $15
         27      > 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/fbtuM
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $json
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $1      
          5      > RETURN                                                   $1
          6*     > RETURN                                                   null

End of Dynamic Function 0

Dynamic Function 1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fbtuM
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $person
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1        ASSIGN_DIM                                               !0, 'type'
          2        OP_DATA                                                  'line'
   21     3      > RETURN                                                   !0
   22     4*     > RETURN                                                   null

End of Dynamic Function 1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.37 ms | 1009 KiB | 18 Q