3v4l.org

run code in 300+ PHP versions simultaneously
<?php $bodycontent = "<p>We've been in business since 1998 and produced this logo design [1995] years ago.</p>\n"; $bodycontent .= "<p>We've been in business since 1998 and produced this website design [2018] years ago.</p>\n"; $bodycontent .= "<p>We've been in business since 1998 and produced this website design [2017] years ago.</p>\n"; $bodycontent .= "<p>We've been in business since 1998 and produced this website design [2016] years ago.</p>"; $lookup=['less than a','one','two','three','four','five','six','seven','eight','nine', 'ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen' ]; // extend as needed $bodycontent = preg_replace_callback('/\[(\d{4})] years ago/', function($m)use($lookup){ $diff=date('Y')-$m[1]; if(isset($lookup[$diff])){ return $lookup[$diff].' year'.($diff>1?'s':'').' ago'; }else{ return "in {$m[1]}"; // out of lookup range, use backup text } }, $bodycontent); echo $bodycontent;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TNNjS
function name:  (null)
number of ops:  15
compiled vars:  !0 = $bodycontent, !1 = $lookup
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '%3Cp%3EWe%27ve+been+in+business+since+1998+and+produced+this+logo+design+%5B1995%5D+years+ago.%3C%2Fp%3E%0A'
    3     1        ASSIGN_OP                                     8          !0, '%3Cp%3EWe%27ve+been+in+business+since+1998+and+produced+this+website+design+%5B2018%5D+years+ago.%3C%2Fp%3E%0A'
    4     2        ASSIGN_OP                                     8          !0, '%3Cp%3EWe%27ve+been+in+business+since+1998+and+produced+this+website+design+%5B2017%5D+years+ago.%3C%2Fp%3E%0A'
    5     3        ASSIGN_OP                                     8          !0, '%3Cp%3EWe%27ve+been+in+business+since+1998+and+produced+this+website+design+%5B2016%5D+years+ago.%3C%2Fp%3E'
    7     4        ASSIGN                                                   !1, <array>
   11     5        INIT_FCALL                                               'preg_replace_callback'
          6        SEND_VAL                                                 '%2F%5C%5B%28%5Cd%7B4%7D%29%5D+years+ago%2F'
          7        DECLARE_LAMBDA_FUNCTION                          ~7      [0]
          8        BIND_LEXICAL                                             ~7, !1
   18     9        SEND_VAL                                                 ~7
         10        SEND_VAR                                                 !0
   11    11        DO_ICALL                                         $8      
         12        ASSIGN                                                   !0, $8
   20    13        ECHO                                                     !0
   21    14      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 21
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 16
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TNNjS
function name:  {closure}
number of ops:  26
compiled vars:  !0 = $m, !1 = $lookup, !2 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   12     2        INIT_FCALL                                               'date'
          3        SEND_VAL                                                 'Y'
          4        DO_ICALL                                         $3      
          5        FETCH_DIM_R                                      ~4      !0, 1
          6        SUB                                              ~5      $3, ~4
          7        ASSIGN                                                   !2, ~5
   13     8        ISSET_ISEMPTY_DIM_OBJ                         0          !1, !2
          9      > JMPZ                                                     ~7, ->21
   14    10    >   FETCH_DIM_R                                      ~8      !1, !2
         11        CONCAT                                           ~9      ~8, '+year'
         12        IS_SMALLER                                               1, !2
         13      > JMPZ                                                     ~10, ->16
         14    >   QM_ASSIGN                                        ~11     's'
         15      > JMP                                                      ->17
         16    >   QM_ASSIGN                                        ~11     ''
         17    >   CONCAT                                           ~12     ~9, ~11
         18        CONCAT                                           ~13     ~12, '+ago'
         19      > RETURN                                                   ~13
   13    20*       JMP                                                      ->25
   16    21    >   NOP                                                      
         22        FETCH_DIM_R                                      ~14     !0, 1
         23        FAST_CONCAT                                      ~15     'in+', ~14
         24      > RETURN                                                   ~15
   18    25*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.09 ms | 1443 KiB | 15 Q