3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = '[{ "id": "5b2a4b0287bc2c082ebc2897", "test_name": "BSF", "test_type": "Pathology", "cost": "100" }, { "id": "5b2a4ac63db998081e7f6c97", "test_name": "Brain & PNS", "test_type": "Radiology", "cost": "1000" }, { "id": "5b2a4ac63db998081e22336c97", "test_name": "BPNS", "test_type": "Radiology", "cost": "1000" }, { "id": "5b2a4ac63db998081e22336c97", "test_name": "BPNS", "test_type": "Somethingelseology", "cost": "1000" }]'; $arr = json_decode($json,true); $type = array_column($arr, "test_type"); Foreach(array_unique($type) as $t){ $new[$t] = array_intersect_key($arr, array_intersect($type, [$t])); } extract($new); var_dump($Radiology, $Pathology, $Somethingelseology);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 15, Position 2 = 28
Branch analysis from position: 15
2 jumps found. (Code = 78) Position 1 = 16, Position 2 = 28
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/Jf0SE
function name:  (null)
number of ops:  38
compiled vars:  !0 = $json, !1 = $arr, !2 = $type, !3 = $t, !4 = $new, !5 = $Radiology, !6 = $Pathology, !7 = $Somethingelseology
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%5B%7B%0A++++%22id%22%3A+%225b2a4b0287bc2c082ebc2897%22%2C%0A++++%22test_name%22%3A+%22BSF%22%2C%0A++++%22test_type%22%3A+%22Pathology%22%2C%0A++++%22cost%22%3A+%22100%22%0A%7D%2C+%7B%0A++++%22id%22%3A+%225b2a4ac63db998081e7f6c97%22%2C%0A++++%22test_name%22%3A+%22Brain+%26+PNS%22%2C%0A++++%22test_type%22%3A+%22Radiology%22%2C%0A++++%22cost%22%3A+%221000%22%0A%7D%2C+%7B%0A++++%22id%22%3A+%225b2a4ac63db998081e22336c97%22%2C%0A++++%22test_name%22%3A+%22BPNS%22%2C%0A++++%22test_type%22%3A+%22Radiology%22%2C%0A++++%22cost%22%3A+%221000%22%0A%7D%2C+%7B%0A++++%22id%22%3A+%225b2a4ac63db998081e22336c97%22%2C%0A++++%22test_name%22%3A+%22BPNS%22%2C%0A++++%22test_type%22%3A+%22Somethingelseology%22%2C%0A++++%22cost%22%3A+%221000%22%0A%7D%5D'
   25     1        INIT_FCALL                                               'json_decode'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 <true>
          4        DO_ICALL                                         $9      
          5        ASSIGN                                                   !1, $9
   26     6        INIT_FCALL                                               'array_column'
          7        SEND_VAR                                                 !1
          8        SEND_VAL                                                 'test_type'
          9        DO_ICALL                                         $11     
         10        ASSIGN                                                   !2, $11
   28    11        INIT_FCALL                                               'array_unique'
         12        SEND_VAR                                                 !2
         13        DO_ICALL                                         $13     
         14      > FE_RESET_R                                       $14     $13, ->28
         15    > > FE_FETCH_R                                               $14, !3, ->28
   29    16    >   INIT_FCALL                                               'array_intersect_key'
         17        SEND_VAR                                                 !1
         18        INIT_FCALL                                               'array_intersect'
         19        SEND_VAR                                                 !2
         20        INIT_ARRAY                                       ~16     !3
         21        SEND_VAL                                                 ~16
         22        DO_ICALL                                         $17     
         23        SEND_VAR                                                 $17
         24        DO_ICALL                                         $18     
         25        ASSIGN_DIM                                               !4, !3
         26        OP_DATA                                                  $18
   28    27      > JMP                                                      ->15
         28    >   FE_FREE                                                  $14
   31    29        INIT_FCALL                                               'extract'
         30        SEND_REF                                                 !4
         31        DO_ICALL                                                 
   32    32        INIT_FCALL                                               'var_dump'
         33        SEND_VAR                                                 !5
         34        SEND_VAR                                                 !6
         35        SEND_VAR                                                 !7
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.79 ms | 1017 KiB | 20 Q