3v4l.org

run code in 500+ PHP versions simultaneously
<?php function uuid_to_bin($uuid){ $bin_uuid = pack("H*", str_replace('-', '', $uuid)); return $bin_uuid; } function bin_to_uuid($binid) { $arr= unpack("H*", $binid); $string = $arr['1']; $string = preg_replace("/([0-9a-f]{8})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{4})([0-9a-f]{12})/", "$1-$2-$3-$4-$5", $string); return $string; } $uuids = [ '9c4ddfc6-6f31-486b-b07e-17cecc493a94', '00000000-0000-0000-0000-000000000000', ]; foreach ($uuids as $uuid) { var_dump($uuid === bin_to_uuid(uuid_to_bin($uuid))); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 14
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/a769C
function name:  (null)
number of ops:  16
compiled vars:  !0 = $uuids, !1 = $uuid
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                       !0, <array>
   20     1      > FE_RESET_R                                           $3      !0, ->14
          2    > > FE_FETCH_R                                                   $3, !1, ->14
   21     3    >   INIT_FCALL                                                   'var_dump'
          4        INIT_FCALL                                                   'bin_to_uuid'
          5        INIT_FCALL                                                   'uuid_to_bin'
          6        SEND_VAR                                                     !1
          7        DO_FCALL                                          0  $4      
          8        SEND_VAR                                                     $4
          9        DO_FCALL                                          0  $5      
         10        IS_IDENTICAL                                         ~6      !1, $5
         11        SEND_VAL                                                     ~6
         12        DO_ICALL                                                     
   20    13      > JMP                                                          ->2
         14    >   FE_FREE                                                      $3
   22    15      > RETURN                                                       1

Function uuid_to_bin:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a769C
function name:  uuid_to_bin
number of ops:  10
compiled vars:  !0 = $uuid, !1 = $bin_uuid
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'pack'
          2        SEND_VAL                                                     'H%2A'
          3        FRAMELESS_ICALL_3                str_replace         ~2      '-', ''
          4        OP_DATA                                                      !0
          5        SEND_VAL                                                     ~2
          6        DO_ICALL                                             $3      
          7        ASSIGN                                                       !1, $3
    5     8      > RETURN                                                       !1
    6     9*     > RETURN                                                       null

End of function uuid_to_bin

Function bin_to_uuid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a769C
function name:  bin_to_uuid
number of ops:  13
compiled vars:  !0 = $binid, !1 = $arr, !2 = $string
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    8     0  E >   RECV                                                 !0      
   10     1        INIT_FCALL                                                   'unpack'
          2        SEND_VAL                                                     'H%2A'
          3        SEND_VAR                                                     !0
          4        DO_ICALL                                             $3      
          5        ASSIGN                                                       !1, $3
   11     6        FETCH_DIM_R                                          ~5      !1, 1
          7        ASSIGN                                                       !2, ~5
   12     8        FRAMELESS_ICALL_3                preg_replace        ~7      '%2F%28%5B0-9a-f%5D%7B8%7D%29%28%5B0-9a-f%5D%7B4%7D%29%28%5B0-9a-f%5D%7B4%7D%29%28%5B0-9a-f%5D%7B4%7D%29%28%5B0-9a-f%5D%7B12%7D%29%2F', '%241-%242-%243-%244-%245'
          9        OP_DATA                                                      !2
         10        ASSIGN                                                       !2, ~7
   13    11      > RETURN                                                       !2
   14    12*     > RETURN                                                       null

End of function bin_to_uuid

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
160.27 ms | 2142 KiB | 18 Q