3v4l.org

run code in 300+ PHP versions simultaneously
<?php function normaliza ($string){ $a = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûýýþÿ'; $b = 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyyby'; $string = utf8_decode($string); $string = strtr($string, utf8_decode($a), $b); $string = strtolower($string); return utf8_encode($string); } function parseStopWords($text){ $tex = normaliza($text); $text = str_replace('¡¿?!', '', $text); $text = preg_replace('/[^a-zA-Z0-9áéíóúñÁÉÍÓÚÑ¡\', ]/i','',$text); $stopwords = array('ante','bajo','cabe','con','contra','de','desde','en','entre','hacia','hasta','para','por','sin','sobre','tras','el','lo','la','los','las','un','unos','una','al','del','que','es','se','y','fue'); foreach($stopwords as $w){ $text = preg_replace('/\b'.$w.'\b/i','',$text); } $text = preg_replace('/\s{2,}/i',' ',$text); $text = str_replace(" a ", "", $text); return $text; } echo parseStopWords('¿Qué ha sido de nuestra niñez?');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a0MrB
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E >   INIT_FCALL                                               'parsestopwords'
          1        SEND_VAL                                                 '%C2%BFQu%C3%A9+ha+sido+de+nuestra+ni%C3%B1ez%3F'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
          4      > RETURN                                                   1

Function normaliza:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/a0MrB
function name:  normaliza
number of ops:  25
compiled vars:  !0 = $string, !1 = $a, !2 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, '%C3%80%C3%81%C3%82%C3%83%C3%84%C3%85%C3%86%C3%87%C3%88%C3%89%C3%8A%C3%8B%C3%8C%C3%8D%C3%8E%C3%8F%C3%90%C3%91%C3%92%C3%93%C3%94%C3%95%C3%96%C3%98%C3%99%C3%9A%C3%9B%C3%9C%C3%9D%C3%9E%C3%9F%C3%A0%C3%A1%C3%A2%C3%A3%C3%A4%C3%A5%C3%A6%C3%A7%C3%A8%C3%A9%C3%AA%C3%AB%C3%AC%C3%AD%C3%AE%C3%AF%C3%B0%C3%B1%C3%B2%C3%B3%C3%B4%C3%B5%C3%B6%C3%B8%C3%B9%C3%BA%C3%BB%C3%BD%C3%BD%C3%BE%C3%BF'
    4     2        ASSIGN                                                   !2, 'aaaaaaaceeeeiiiidnoooooouuuuybsaaaaaaaceeeeiiiidnoooooouuuyyby'
    5     3        INIT_FCALL                                               'utf8_decode'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $5      
          6        ASSIGN                                                   !0, $5
    6     7        INIT_FCALL                                               'strtr'
          8        SEND_VAR                                                 !0
          9        INIT_FCALL                                               'utf8_decode'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $7      
         12        SEND_VAR                                                 $7
         13        SEND_VAR                                                 !2
         14        DO_ICALL                                         $8      
         15        ASSIGN                                                   !0, $8
    7    16        INIT_FCALL                                               'strtolower'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $10     
         19        ASSIGN                                                   !0, $10
    8    20        INIT_FCALL                                               'utf8_encode'
         21        SEND_VAR                                                 !0
         22        DO_ICALL                                         $12     
         23      > RETURN                                                   $12
    9    24*     > RETURN                                                   null

End of function normaliza

Function parsestopwords:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 29
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/a0MrB
function name:  parseStopWords
number of ops:  44
compiled vars:  !0 = $text, !1 = $tex, !2 = $stopwords, !3 = $w
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        INIT_FCALL                                               'normaliza'
          2        SEND_VAR                                                 !0
          3        DO_FCALL                                      0  $4      
          4        ASSIGN                                                   !1, $4
   13     5        INIT_FCALL                                               'str_replace'
          6        SEND_VAL                                                 '%C2%A1%C2%BF%3F%21'
          7        SEND_VAL                                                 ''
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $6      
         10        ASSIGN                                                   !0, $6
   14    11        INIT_FCALL                                               'preg_replace'
         12        SEND_VAL                                                 '%2F%5B%5Ea-zA-Z0-9%C3%A1%C3%A9%C3%AD%C3%B3%C3%BA%C3%B1%C3%81%C3%89%C3%8D%C3%93%C3%9A%C3%91%C2%A1%27%2C+%5D%2Fi'
         13        SEND_VAL                                                 ''
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $8      
         16        ASSIGN                                                   !0, $8
   15    17        ASSIGN                                                   !2, <array>
   17    18      > FE_RESET_R                                       $11     !2, ->29
         19    > > FE_FETCH_R                                               $11, !3, ->29
   18    20    >   INIT_FCALL                                               'preg_replace'
         21        CONCAT                                           ~12     '%2F%5Cb', !3
         22        CONCAT                                           ~13     ~12, '%5Cb%2Fi'
         23        SEND_VAL                                                 ~13
         24        SEND_VAL                                                 ''
         25        SEND_VAR                                                 !0
         26        DO_ICALL                                         $14     
         27        ASSIGN                                                   !0, $14
   17    28      > JMP                                                      ->19
         29    >   FE_FREE                                                  $11
   20    30        INIT_FCALL                                               'preg_replace'
         31        SEND_VAL                                                 '%2F%5Cs%7B2%2C%7D%2Fi'
         32        SEND_VAL                                                 '+'
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                         $16     
         35        ASSIGN                                                   !0, $16
   21    36        INIT_FCALL                                               'str_replace'
         37        SEND_VAL                                                 '+a+'
         38        SEND_VAL                                                 ''
         39        SEND_VAR                                                 !0
         40        DO_ICALL                                         $18     
         41        ASSIGN                                                   !0, $18
   22    42      > RETURN                                                   !0
   23    43*     > RETURN                                                   null

End of function parsestopwords

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.06 ms | 1407 KiB | 27 Q