3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); error_reporting(-1); mb_internal_encoding('utf-8'); //$text = "ну что. не смотрел еще black mesa.я собирался скачать ,но все как-то некогда было."; // Для тестовФ $text = "roses are red,and violets are blue.whatever you do i'll keep it for you."; // $text = 'привет.есть 2 функции,preg_split и explode ,не понимаю,в чем между ними разница.'; function makeFirst($stringsLetter) { //ucfirst ( $text ); не юзает кириллицу // $str = mb_strtoupper($str); не работает, впрочем также как и конверт_кейс $stringsLetter = mb_strtoupper(mb_substr($stringsLetter, 0, 1)) . mb_substr($stringsLetter, 1, NULL); return $stringsLetter; //echo gettype($str); } //пока не делал фикс, но не думаю что это сложно function fixText($text) { $text = preg_replace('/\s{2,10}/u', "", $text); return $text; } $vartext = array(); $vartext = preg_split('/(?<=\.)(\s+|)/u', $text, -1, PREG_SPLIT_NO_EMPTY); //var_dump($vartext); foreach ($vartext as $stringsLetters) { //echo "без изменений - "; // echo $stringsLetters; echo "\n \n"; $stringsLetter = fixText($stringsLetters); echo $stringsLetter; echo "тут должна быть большая буковка - "; $stringsLetter = makeFirst($stringsLetters); echo $stringsLetter; echo "\n\n "; // var_dump( $stringsLetters); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 34
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 34
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
filename:       /in/D0i7tk
function name:  (null)
number of ops:  36
compiled vars:  !0 = $text, !1 = $vartext, !2 = $stringsLetters, !3 = $stringsLetter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
    6     3        INIT_FCALL                                               'error_reporting'
          4        SEND_VAL                                                 -1
          5        DO_ICALL                                                 
    7     6        INIT_FCALL                                               'mb_internal_encoding'
          7        SEND_VAL                                                 'utf-8'
          8        DO_ICALL                                                 
   11     9        ASSIGN                                                   !0, 'roses+are+red%2Cand+violets+are+blue.whatever+you+do+i%27ll+keep+it+for+you.'
   35    10        ASSIGN                                                   !1, <array>
   36    11        INIT_FCALL                                               'preg_split'
         12        SEND_VAL                                                 '%2F%28%3F%3C%3D%5C.%29%28%5Cs%2B%7C%29%2Fu'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 -1
         15        SEND_VAL                                                 1
         16        DO_ICALL                                         $9      
         17        ASSIGN                                                   !1, $9
   40    18      > FE_RESET_R                                       $11     !1, ->34
         19    > > FE_FETCH_R                                               $11, !2, ->34
   44    20    >   ECHO                                                     '%0A+%0A'
   46    21        INIT_FCALL                                               'fixtext'
         22        SEND_VAR                                                 !2
         23        DO_FCALL                                      0  $12     
         24        ASSIGN                                                   !3, $12
   47    25        ECHO                                                     !3
   49    26        ECHO                                                     '%D1%82%D1%83%D1%82+%D0%B4%D0%BE%D0%BB%D0%B6%D0%BD%D0%B0+%D0%B1%D1%8B%D1%82%D1%8C+%D0%B1%D0%BE%D0%BB%D1%8C%D1%88%D0%B0%D1%8F+%D0%B1%D1%83%D0%BA%D0%BE%D0%B2%D0%BA%D0%B0+-+'
   51    27        INIT_FCALL                                               'makefirst'
         28        SEND_VAR                                                 !2
         29        DO_FCALL                                      0  $14     
         30        ASSIGN                                                   !3, $14
   52    31        ECHO                                                     !3
   54    32        ECHO                                                     '%0A%0A+'
   40    33      > JMP                                                      ->19
         34    >   FE_FREE                                                  $11
   58    35      > RETURN                                                   1

Function makefirst:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D0i7tk
function name:  makeFirst
number of ops:  18
compiled vars:  !0 = $stringsLetter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   20     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        SEND_VAL                                                 null
         13        DO_ICALL                                         $3      
         14        CONCAT                                           ~4      $2, $3
         15        ASSIGN                                                   !0, ~4
   22    16      > RETURN                                                   !0
   26    17*     > RETURN                                                   null

End of function makefirst

Function fixtext:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D0i7tk
function name:  fixText
number of ops:  9
compiled vars:  !0 = $text
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   RECV                                             !0      
   31     1        INIT_FCALL                                               'preg_replace'
          2        SEND_VAL                                                 '%2F%5Cs%7B2%2C10%7D%2Fu'
          3        SEND_VAL                                                 ''
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $1      
          6        ASSIGN                                                   !0, $1
   32     7      > RETURN                                                   !0
   33     8*     > RETURN                                                   null

End of function fixtext

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.22 ms | 1403 KiB | 27 Q