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);
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
array ( 0 => 'ACHNANTHES', 1 => 'Achnanthes brevipes', 2 => 'Achnanthes coarctata', 3 => 'Achnanthes cocconeiformis', 4 => 'Achnanthes gibberula', 5 => 'Achnanthes lacunarum', 6 => 'Achnanthes lineariformis', 7 => 'Achnanthes longipes', 8 => 'Achnanthes nollii', 9 => 'Achnanthes parvula', 10 => 'Achnanthes petersenii', 11 => 'Achnanthes pyrenaicum', 12 => 'Achnanthes stolida', 13 => 'Achnanthes thermalis', 14 => 'Achnanthes trinodis', 15 => 'Achnanthes wellsiae', 16 => 'PLATESSA', 17 => 'Platessa conspicua', 18 => 'Platessa montana', 19 => 'Platessa salinarum', 20 => 'ACHNANTHIDIUM', 21 => 'Achnanthidium affine', 22 => 'Achnanthidium deflexum', 23 => 'Achnanthidium exiguum', 24 => 'Achnanthidium exile', 25 => 'Achnanthidium lanceolatum', 26 => 'Achnanthidium minutissimum', 27 => 'Achnanthidium minutum', 28 => 'Achnanthidium thermale', 29 => 'EUCOCCONEIS', 30 => 'Eucocconeis flexella', 31 => 'Eucocconeis laevis', 32 => 'Eucocconeis quadratarea', )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
164.66 ms | 408 KiB | 5 Q