3v4l.org

run code in 300+ PHP versions simultaneously
<?php function lastinteger($item) { preg_match_all('/data-id=[\"\']([1-9]+)[\"\']/',$item,$array); $out = end($array); return $out[0]; } $path1 = "<span class='span1' data-id='2'>lorem ipsum</span>"; $path2 = "<span class='span2' data-id='14'>lorem ipsum</span>"; $a = lastinteger($path1); //2 $b = lastinteger($path2); //14 echo $a." ".$b;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hgOUk
function name:  (null)
number of ops:  14
compiled vars:  !0 = $path1, !1 = $path2, !2 = $a, !3 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSIGN                                                   !0, '%3Cspan+class%3D%27span1%27+data-id%3D%272%27%3Elorem+ipsum%3C%2Fspan%3E'
   12     1        ASSIGN                                                   !1, '%3Cspan+class%3D%27span2%27+data-id%3D%2714%27%3Elorem+ipsum%3C%2Fspan%3E'
   14     2        INIT_FCALL                                               'lastinteger'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !2, $6
   15     6        INIT_FCALL                                               'lastinteger'
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !3, $8
   17    10        CONCAT                                           ~10     !2, '+'
         11        CONCAT                                           ~11     ~10, !3
         12        ECHO                                                     ~11
         13      > RETURN                                                   1

Function lastinteger:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hgOUk
function name:  lastinteger
number of ops:  13
compiled vars:  !0 = $item, !1 = $array, !2 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2Fdata-id%3D%5B%5C%22%27%5D%28%5B1-9%5D%2B%29%5B%5C%22%27%5D%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
    6     6        INIT_FCALL                                               'end'
          7        SEND_REF                                                 !1
          8        DO_ICALL                                         $4      
          9        ASSIGN                                                   !2, $4
    8    10        FETCH_DIM_R                                      ~6      !2, 0
         11      > RETURN                                                   ~6
    9    12*     > RETURN                                                   null

End of function lastinteger

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.84 ms | 1009 KiB | 17 Q