3v4l.org

run code in 300+ PHP versions simultaneously
<?php function parseErrorMessage($string) { foreach(explode(PHP_EOL, $string) as $line){ // split on end of lines list($label,$message)=explode(' - ',$line,2); // limit the explosion to 2 elements $result[$label]=$message; // append to result array using first half and second half of line } return $result; } $string ="Error Type - Database Error Message - Error Executing Database Something is wrong. Error Detail - [Macromedia][SQLServer JDBC Driver][SQLServer]Incorrect syntax ne-ar '1'."; print_r(parseErrorMessage($string));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BlbKu
function name:  (null)
number of ops:  8
compiled vars:  !0 = $string
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, 'Error+Type+-+Database%0AError+Message+-+Error+Executing+Database+Something+is+wrong.%0AError+Detail+-+%5BMacromedia%5D%5BSQLServer+JDBC+Driver%5D%5BSQLServer%5DIncorrect+syntax+ne-ar+%271%27.'
   14     1        INIT_FCALL                                               'print_r'
          2        INIT_FCALL                                               'parseerrormessage'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function parseerrormessage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 20
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 20
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/BlbKu
function name:  parseErrorMessage
number of ops:  23
compiled vars:  !0 = $string, !1 = $line, !2 = $label, !3 = $message, !4 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5      > FE_RESET_R                                       $6      $5, ->20
          6    > > FE_FETCH_R                                               $6, !1, ->20
    4     7    >   INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '+-+'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 2
         11        DO_ICALL                                         $7      
         12        FETCH_LIST_R                                     $8      $7, 0
         13        ASSIGN                                                   !2, $8
         14        FETCH_LIST_R                                     $10     $7, 1
         15        ASSIGN                                                   !3, $10
         16        FREE                                                     $7
    5    17        ASSIGN_DIM                                               !4, !2
         18        OP_DATA                                                  !3
    3    19      > JMP                                                      ->6
         20    >   FE_FREE                                                  $6
    7    21      > RETURN                                                   !4
    8    22*     > RETURN                                                   null

End of function parseerrormessage

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.91 ms | 1399 KiB | 18 Q