3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); mb_internal_encoding('utf-8'); //$text = "Кажется, нас обнаружили! Надо срочно уходить отсюда, пока не поздно. Бежим же скорее!"; // Другие варианты для тестов //$text = "Ну, прости меня! Не хотела я тебе зла сделать; да в себе не вольна была. Что говорила, что делала, себя не помнила."; $text = "Идет гражданская война. Космические корабли повстанцев, наносящие удар с тайной базы, одержали первую победу, в схватке со зловещей Галактической Империей."; /* Делает первую букву предложения заглавной */ function makeFirstletterUppercase($text) { return mb_strtoupper(mb_substr($text, 0, 1)).mb_substr($text, 1); } function makeYodaStyleText($text) { $text = preg_replace('/,/', '', $text); $text = mb_strtolower($text); $offers = preg_split('/([.!?;][ ])|[.!?;]/', $text, 0 , PREG_SPLIT_NO_EMPTY); foreach ($offers as &$value) { $words = array(); $words = preg_split('/[ ]/', $value, 0, PREG_SPLIT_NO_EMPTY); $words = array_reverse($words); $value = implode(" ", $words); $value = makeFirstletterUppercase($value); } $text = implode(". ", $offers); return $text; } $yodaText = makeYodaStyleText($text); echo "Йода говорит: {$yodaText}\n";
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/46mlk
function name:  (null)
number of ops:  16
compiled vars:  !0 = $text, !1 = $yodaText
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
    4     3        INIT_FCALL                                               'mb_internal_encoding'
          4        SEND_VAL                                                 'utf-8'
          5        DO_ICALL                                                 
    9     6        ASSIGN                                                   !0, '%D0%98%D0%B4%D0%B5%D1%82+%D0%B3%D1%80%D0%B0%D0%B6%D0%B4%D0%B0%D0%BD%D1%81%D0%BA%D0%B0%D1%8F+%D0%B2%D0%BE%D0%B9%D0%BD%D0%B0.+%D0%9A%D0%BE%D1%81%D0%BC%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%B8%D0%B5+%D0%BA%D0%BE%D1%80%D0%B0%D0%B1%D0%BB%D0%B8+%D0%BF%D0%BE%D0%B2%D1%81%D1%82%D0%B0%D0%BD%D1%86%D0%B5%D0%B2%2C+%D0%BD%D0%B0%D0%BD%D0%BE%D1%81%D1%8F%D1%89%D0%B8%D0%B5+%D1%83%D0%B4%D0%B0%D1%80+%D1%81+%D1%82%D0%B0%D0%B9%D0%BD%D0%BE%D0%B9+%D0%B1%D0%B0%D0%B7%D1%8B%2C+%D0%BE%D0%B4%D0%B5%D1%80%D0%B6%D0%B0%D0%BB%D0%B8+%D0%BF%D0%B5%D1%80%D0%B2%D1%83%D1%8E+%D0%BF%D0%BE%D0%B1%D0%B5%D0%B4%D1%83%2C+%D0%B2+%D1%81%D1%85%D0%B2%D0%B0%D1%82%D0%BA%D0%B5+%D1%81%D0%BE+%D0%B7%D0%BB%D0%BE%D0%B2%D0%B5%D1%89%D0%B5%D0%B9+%D0%93%D0%B0%D0%BB%D0%B0%D0%BA%D1%82%D0%B8%D1%87%D0%B5%D1%81%D0%BA%D0%BE%D0%B9+%D0%98%D0%BC%D0%BF%D0%B5%D1%80%D0%B8%D0%B5%D0%B9.'
   34     7        INIT_FCALL                                               'makeyodastyletext'
          8        SEND_VAR                                                 !0
          9        DO_FCALL                                      0  $5      
         10        ASSIGN                                                   !1, $5
   35    11        ROPE_INIT                                     3  ~8      '%D0%99%D0%BE%D0%B4%D0%B0+%D0%B3%D0%BE%D0%B2%D0%BE%D1%80%D0%B8%D1%82%3A+'
         12        ROPE_ADD                                      1  ~8      ~8, !1
         13        ROPE_END                                      2  ~7      ~8, '%0A'
         14        ECHO                                                     ~7
         15      > RETURN                                                   1

Function makefirstletteruppercase:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/46mlk
function name:  makeFirstletterUppercase
number of ops:  16
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
   13     1        INIT_FCALL                                               'mb_strtoupper'
          2        INIT_FCALL                                               'mb_substr'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 0
          5        SEND_VAL                                                 1
          6        DO_ICALL                                         $1      
          7        SEND_VAR                                                 $1
          8        DO_ICALL                                         $2      
          9        INIT_FCALL                                               'mb_substr'
         10        SEND_VAR                                                 !0
         11        SEND_VAL                                                 1
         12        DO_ICALL                                         $3      
         13        CONCAT                                           ~4      $2, $3
         14      > RETURN                                                   ~4
   14    15*     > RETURN                                                   null

End of function makefirstletteruppercase

Function makeyodastyletext:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 19, Position 2 = 42
Branch analysis from position: 19
2 jumps found. (Code = 126) Position 1 = 20, Position 2 = 42
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 42
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 42
filename:       /in/46mlk
function name:  makeYodaStyleText
number of ops:  50
compiled vars:  !0 = $text, !1 = $offers, !2 = $value, !3 = $words
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%2C%2F'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $4      
          6        ASSIGN                                                   !0, $4
   18     7        INIT_FCALL                                               'mb_strtolower'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $6      
         10        ASSIGN                                                   !0, $6
   19    11        INIT_FCALL                                               'preg_split'
         12        SEND_VAL                                                 '%2F%28%5B.%21%3F%3B%5D%5B+%5D%29%7C%5B.%21%3F%3B%5D%2F'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 0
         15        SEND_VAL                                                 1
         16        DO_ICALL                                         $8      
         17        ASSIGN                                                   !1, $8
   21    18      > FE_RESET_RW                                      $10     !1, ->42
         19    > > FE_FETCH_RW                                              $10, !2, ->42
   22    20    >   ASSIGN                                                   !3, <array>
   23    21        INIT_FCALL                                               'preg_split'
         22        SEND_VAL                                                 '%2F%5B+%5D%2F'
         23        SEND_VAR                                                 !2
         24        SEND_VAL                                                 0
         25        SEND_VAL                                                 1
         26        DO_ICALL                                         $12     
         27        ASSIGN                                                   !3, $12
   24    28        INIT_FCALL                                               'array_reverse'
         29        SEND_VAR                                                 !3
         30        DO_ICALL                                         $14     
         31        ASSIGN                                                   !3, $14
   25    32        INIT_FCALL                                               'implode'
         33        SEND_VAL                                                 '+'
         34        SEND_VAR                                                 !3
         35        DO_ICALL                                         $16     
         36        ASSIGN                                                   !2, $16
   27    37        INIT_FCALL                                               'makefirstletteruppercase'
         38        SEND_VAR                                                 !2
         39        DO_FCALL                                      0  $18     
         40        ASSIGN                                                   !2, $18
   21    41      > JMP                                                      ->19
         42    >   FE_FREE                                                  $10
   30    43        INIT_FCALL                                               'implode'
         44        SEND_VAL                                                 '.+'
         45        SEND_VAR                                                 !1
         46        DO_ICALL                                         $20     
         47        ASSIGN                                                   !0, $20
   31    48      > RETURN                                                   !0
   32    49*     > RETURN                                                   null

End of function makeyodastyletext

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.72 ms | 1018 KiB | 24 Q