3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Get real file from code id */ // nl2p // This function will convert newlines to HTML paragraphs // without paying attention to HTML tags. Feed it a raw string and it will // simply return that string sectioned into HTML paragraphs function nl2p($str) { $arr=explode("\n",$str); $out=''; for($i=0;$i<count($arr);$i++) { if(strlen(trim($arr[$i]))>0) $out.='<p>'.trim($arr[$i]).'</p>'; } return $out; } // nl2p_html // This function will add paragraph tags around textual content of an HTML file, leaving // the HTML itself intact // This function assumes that the HTML syntax is correct and that the '<' and '>' characters // are not used in any of the values for any tag attributes. If these assumptions are not met, // mass paragraph chaos may ensue. Be safe. function nl2p_html($str) { // If we find the end of an HTML header, assume that this is part of a standard HTML file. Cut off everything including the // end of the head and save it in our output string, then trim the head off of the input. This is mostly because we don't // want to surrount anything like the HTML title tag or any style or script code in paragraph tags. if(strpos($str,'</head>')!==false) { $out=substr($str,0,strpos($str,'</head>')+7); $str=substr($str,strpos($str,'</head>')+7); } } // test $string = "Submissions found to be in violation of these rules may be removed and the author's account suspended at the discretion of the site administrators and/or moderators. The site administrators reserve the right to modify these rules as needed."; $para = nl2p($string); echo $para; ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CMpO0
function name:  (null)
number of ops:  7
compiled vars:  !0 = $string, !1 = $para
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   ASSIGN                                                   !0, 'Submissions+found+to+be+in+violation+of+these+rules+may+be+removed+and+the+author%27s+account+suspended+at+the+discretion+of+the+site+administrators+and%2For+moderators.+The+site+administrators+reserve+the+right+to+modify+these+rules+as+needed.'
   45     1        INIT_FCALL                                               'nl2p'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $3      
          4        ASSIGN                                                   !1, $3
   47     5        ECHO                                                     !1
   49     6      > RETURN                                                   1

Function nl2p:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 9
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 23
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 9
Branch analysis from position: 27
Branch analysis from position: 9
Branch analysis from position: 23
filename:       /in/CMpO0
function name:  nl2p
number of ops:  29
compiled vars:  !0 = $str, !1 = $arr, !2 = $out, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%0A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !1, $4
   14     6        ASSIGN                                                   !2, ''
   16     7        ASSIGN                                                   !3, 0
          8      > JMP                                                      ->24
   17     9    >   INIT_FCALL                                               'trim'
         10        FETCH_DIM_R                                      ~8      !1, !3
         11        SEND_VAL                                                 ~8
         12        DO_ICALL                                         $9      
         13        STRLEN                                           ~10     $9
         14        IS_SMALLER                                               0, ~10
         15      > JMPZ                                                     ~11, ->23
   18    16    >   INIT_FCALL                                               'trim'
         17        FETCH_DIM_R                                      ~12     !1, !3
         18        SEND_VAL                                                 ~12
         19        DO_ICALL                                         $13     
         20        CONCAT                                           ~14     '%3Cp%3E', $13
         21        CONCAT                                           ~15     ~14, '%3C%2Fp%3E'
         22        ASSIGN_OP                                     8          !2, ~15
   16    23    >   PRE_INC                                                  !3
         24    >   COUNT                                            ~18     !1
         25        IS_SMALLER                                               !3, ~18
         26      > JMPNZ                                                    ~19, ->9
   20    27    > > RETURN                                                   !2
   21    28*     > RETURN                                                   null

End of function nl2p

Function nl2p_html:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 28
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/CMpO0
function name:  nl2p_html
number of ops:  29
compiled vars:  !0 = $str, !1 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
   37     1        INIT_FCALL                                               'strpos'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 '%3C%2Fhead%3E'
          4        DO_ICALL                                         $2      
          5        TYPE_CHECK                                  1018          $2
          6      > JMPZ                                                     ~3, ->28
   38     7    >   INIT_FCALL                                               'substr'
          8        SEND_VAR                                                 !0
          9        SEND_VAL                                                 0
         10        INIT_FCALL                                               'strpos'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 '%3C%2Fhead%3E'
         13        DO_ICALL                                         $4      
         14        ADD                                              ~5      $4, 7
         15        SEND_VAL                                                 ~5
         16        DO_ICALL                                         $6      
         17        ASSIGN                                                   !1, $6
   39    18        INIT_FCALL                                               'substr'
         19        SEND_VAR                                                 !0
         20        INIT_FCALL                                               'strpos'
         21        SEND_VAR                                                 !0
         22        SEND_VAL                                                 '%3C%2Fhead%3E'
         23        DO_ICALL                                         $8      
         24        ADD                                              ~9      $8, 7
         25        SEND_VAL                                                 ~9
         26        DO_ICALL                                         $10     
         27        ASSIGN                                                   !0, $10
   41    28    > > RETURN                                                   null

End of function nl2p_html

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.19 ms | 1403 KiB | 22 Q