3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ 0 => 'ACHNANTHES Bory, Dict. Class. Hist. Nat. 1: 79 (1822). / SUCINCIĞI.', 1 => 'A. brevipes C.Agardh, Syst. Alg.: 1 (1824). / Küçük sucıncığı.', 2 => 'A. coarctata (Bréb. ex W.Sm.) Grunow, Syn. Diat. Belg.: expl. pl. XXVI: ş. 17 (1880). / Dar sucıncığı.', 3 => 'A. cocconeiformis Mann, U.S. Nat. Mus., Bull. 6: 182 (1925). / Top sucıncığı.', 4 => 'A. gibberula Grunow, Kongl. Svenska Vetensk.-Akad. Handl. 17(2): 121 (1880). / Kambur sucıncığı.', 5 => 'A. lacunarum Hust., Bacillariophyta (Diatomeae) Zweite Auflage, Süsswass.-Fl. Mitteleurop. 10: 205 (1930). / Delikli sucıncığı.', 6 => 'A. lineariformis Lange-Bert., Biblioth. Diatomol. 27: 7, 134 pl. (1993). / Düz sucıncığı.', 7 => 'A. longipes C.Agardh, Syst. Alg.: 1 (1824). / Boylu sucıncığı.', 8 => 'A. nollii Bock, Nachrichtendes Naturwiss. Museums Stadt Aschaffenburg 38: 1 (1953). / Yaban sucıncığı.', 9 => 'A. parvula Kütz., Bacillarien: 76, pl. 21: ş. 5 (1844). / Saf sucıncığı.', 10 => 'A. petersenii Hust., Rabenhorst’s Krypt.-Fl. Deutschl.: 179, ş 10-14 (1937). / Bal sucıncığı.', 11 => 'A. pyrenaicum (Hust.) H.Kobayasi, Nova Hedwigia 65(1-4): 148, ş. 1-18 (1997). / Garip sucıncığı.', 12 => 'A. stolida (Krasske) Krasske, Ann. Acad. Sc. Fenn., ser. A, Biol. 14: 78 (1949). / Alık sucıncığı.', 13 => 'A. thermalis (Rabenh.) Schoenfeld, Diat. German.: 122 (1907). / Sıcak sucıncığı.', 14 => 'A. trinodis (Ralfs) Grunow, Syn. Diatom. Belg.: pl. XXVII: ş. 50 (1880). / Üç sucıncığı.', 15 => 'A. wellsiae Reimer, Monogr. Acad. Nat. Sci. Philadelphia 1: 16 (1966). / El sucıncığı.', 16 => 'PLATESSA Lange-Bert., Süsswass.-Fl. Mitteleuropa 2: 443 (2004). / SUTANESİ.', 17 => 'P. conspicua (Ant.Mayer) Lange-Bert., Süsswass.-Fl. Mitteleuropa 2: 445 (2004). / Küt sutanesi.', 18 => 'P. montana (Krasske) Lange-Bert., Süsswass.-Fl. Mitteleuropa 2: 445 (2004). / Dağ sutanesi.', 19 => 'P. salinarum (Grunow) Lange-Bert. / Sutanesi.', 20 => 'ACHNANTHIDIUM Kütz., Bacillarien: 75 (1844). / SUÇUBUĞU.', 21 => 'A. affine (Grunow) Czarn., Mem. Calif. Acad. Sci. 17: 156 (1994). / Hoş suçubuğu.', 22 => 'A. deflexum Kingston, Diatom Res. 15(2): 409 (2000). / Kıvrık suçubuğu.', 23 => 'A. exiguum (Grunow) Czarnecki, Mem. Calif. Acad. Sci. 17: 155 (1994). / Delikli suçubuğu.', 24 => 'A. exile (Kütz.) Heiberg, Conspect. Diatom. Dan.: 119 (1863). / Bitik suçubuğu.', 25 => 'A. lanceolatum (Bréb.) Kütz., Bot. Zeitung 4(14): 247 (1846). / Uzun suçubuğu.', 26 => 'A. minutissimum (Kütz.) Czarn., Mem. Calif. Acad. Sci. 17: 155 (1994). / Cüce suçubuğu.', 27 => 'A. minutum Cleve, Fl. Fenn. 8(2): 1 (1891). / Bodur suçubuğu.', 28 => 'A. thermale Rabenh., Fl. Eur. Alg. 1: 107 (1864). / Sıcak suçubuğu.', 29 => 'EUCOCCONEIS Cleve ex Meister, Beitr. Kryptogamenfl. Schweiz IV(1): 95 (1912). / SUESNEĞİ.', 30 => 'E. flexella (Kütz.) Meister, Beitr. Kryptogamenfl. Schweiz IV(1): 95 (1912). / Suesneği.', 31 => 'E. laevis (Østrup) Lange-Bert., Iconogr. Diatomol. 6: 46 (1999). / Pek suesneği.', 32 => 'E. quadratarea (Østrup) Lange-Bert., Iconogr. Diatomol. 6: 48 (1999). / Dört suesneği.', ]; $result = []; $currentGenus = null; foreach ($array as $line) { $firstWord = strstr($line, ' ', true); if (ctype_upper($firstWord)) { $currentGenus = $firstWord; $result[] = $firstWord; } else { $result[] = ucfirst(strtolower($currentGenus)) . ' ' . explode(' ', $line, 3)[1]; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 36
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 36
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 15, Position 2 = 19
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/V8uAE
function name:  (null)
number of ops:  41
compiled vars:  !0 = $array, !1 = $result, !2 = $currentGenus, !3 = $line, !4 = $firstWord
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   39     1        ASSIGN                                                   !1, <array>
   40     2        ASSIGN                                                   !2, null
   41     3      > FE_RESET_R                                       $8      !0, ->36
          4    > > FE_FETCH_R                                               $8, !3, ->36
   42     5    >   INIT_FCALL                                               'strstr'
          6        SEND_VAR                                                 !3
          7        SEND_VAL                                                 '+'
          8        SEND_VAL                                                 <true>
          9        DO_ICALL                                         $9      
         10        ASSIGN                                                   !4, $9
   43    11        INIT_FCALL                                               'ctype_upper'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $11     
         14      > JMPZ                                                     $11, ->19
   44    15    >   ASSIGN                                                   !2, !4
   45    16        ASSIGN_DIM                                               !1
         17        OP_DATA                                                  !4
   43    18      > JMP                                                      ->35
   47    19    >   INIT_FCALL                                               'ucfirst'
         20        INIT_FCALL                                               'strtolower'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $15     
         23        SEND_VAR                                                 $15
         24        DO_ICALL                                         $16     
         25        CONCAT                                           ~17     $16, '+'
         26        INIT_FCALL                                               'explode'
         27        SEND_VAL                                                 '+'
         28        SEND_VAR                                                 !3
         29        SEND_VAL                                                 3
         30        DO_ICALL                                         $18     
         31        FETCH_DIM_R                                      ~19     $18, 1
         32        CONCAT                                           ~20     ~17, ~19
         33        ASSIGN_DIM                                               !1
         34        OP_DATA                                                  ~20
   41    35    > > JMP                                                      ->4
         36    >   FE_FREE                                                  $8
   50    37        INIT_FCALL                                               'var_export'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.08 ms | 1015 KiB | 19 Q