3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'NAME OF ITEM 123456789012 OTHER NAME 987654321098 NAME 567890123456'; preg_match_all( '/^(.*?)\s+(\d{12})(?=\D|$)/m', $str, $matches); $items = array(); foreach( $matches[2] as $k => $upc) { $items[$upc] = $matches[1][$k]; } echo $items['987654321098']; // OTHER NAME
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/MH0Lk
function name:  (null)
number of ops:  20
compiled vars:  !0 = $str, !1 = $matches, !2 = $items, !3 = $upc, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, 'NAME+OF+ITEM+123456789012%0AOTHER+NAME+++987654321098%0ANAME+++++++++567890123456'
    5     1        INIT_FCALL                                               'preg_match_all'
          2        SEND_VAL                                                 '%2F%5E%28.%2A%3F%29%5Cs%2B%28%5Cd%7B12%7D%29%28%3F%3D%5CD%7C%24%29%2Fm'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                                 
    7     6        ASSIGN                                                   !2, <array>
    8     7        FETCH_DIM_R                                      ~8      !1, 2
          8      > FE_RESET_R                                       $9      ~8, ->16
          9    > > FE_FETCH_R                                       ~10     $9, !3, ->16
         10    >   ASSIGN                                                   !4, ~10
    9    11        FETCH_DIM_R                                      ~13     !1, 1
         12        FETCH_DIM_R                                      ~14     ~13, !4
         13        ASSIGN_DIM                                               !2, !3
         14        OP_DATA                                                  ~14
    8    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $9
   11    17        FETCH_DIM_R                                      ~15     !2, 987654321098
         18        ECHO                                                     ~15
         19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.61 ms | 1395 KiB | 15 Q