3v4l.org

run code in 500+ 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 = 16, Position 2 = 36
Branch analysis from position: 16
2 jumps found. (Code = 126) Position 1 = 17, Position 2 = 36
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/46mlk
function name:  makeYodaStyleText
number of ops:  41
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        FRAMELESS_ICALL_3                preg_replace        ~4      '%2F%2C%2F', ''
          2        OP_DATA                                                      !0
          3        ASSIGN                                                       !0, ~4
   18     4        INIT_FCALL                                                   'mb_strtolower'
          5        SEND_VAR                                                     !0
          6        DO_ICALL                                             $6      
          7        ASSIGN                                                       !0, $6
   19     8        INIT_FCALL                                                   'preg_split'
          9        SEND_VAL                                                     '%2F%28%5B.%21%3F%3B%5D%5B+%5D%29%7C%5B.%21%3F%3B%5D%2F'
         10        SEND_VAR                                                     !0
         11        SEND_VAL                                                     0
         12        SEND_VAL                                                     1
         13        DO_ICALL                                             $8      
         14        ASSIGN                                                       !1, $8
   21    15      > FE_RESET_RW                                          $10     !1, ->36
         16    > > FE_FETCH_RW                                                  $10, !2, ->36
   22    17    >   ASSIGN                                                       !3, <array>
   23    18        INIT_FCALL                                                   'preg_split'
         19        SEND_VAL                                                     '%2F%5B+%5D%2F'
         20        SEND_VAR                                                     !2
         21        SEND_VAL                                                     0
         22        SEND_VAL                                                     1
         23        DO_ICALL                                             $12     
         24        ASSIGN                                                       !3, $12
   24    25        INIT_FCALL                                                   'array_reverse'
         26        SEND_VAR                                                     !3
         27        DO_ICALL                                             $14     
         28        ASSIGN                                                       !3, $14
   25    29        FRAMELESS_ICALL_2                implode             ~16     '+', !3
         30        ASSIGN                                                       !2, ~16
   27    31        INIT_FCALL                                                   'makefirstletteruppercase'
         32        SEND_VAR                                                     !2
         33        DO_FCALL                                          0  $18     
         34        ASSIGN                                                       !2, $18
   21    35      > JMP                                                          ->16
         36    >   FE_FREE                                                      $10
   30    37        FRAMELESS_ICALL_2                implode             ~20     '.+', !1
         38        ASSIGN                                                       !0, ~20
   31    39      > RETURN                                                       !0
   32    40*     > RETURN                                                       null

End of function makeyodastyletext

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
180.26 ms | 2147 KiB | 22 Q