3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sepChmp = '`'; $dlmtTxt = '§'; $sepLigne = "\v"; $chaines = '§Laurent TOGIER§`§19\` Rue Bréa§`75006`PARIS'. $sepLigne . 'Laurent TOGIER`§\` Rue Bréa§`75006`PARIS'. $sepLigne . 'Laurent TOGIER`§19\`§`75006`PARIS'. $sepLigne . 'Laurent TOGIER`§\`§`75006`PARIS'. $sepLigne . 'Laurent TOGIER`§19\` Rue\` Bréa§`75006`PARIS '. $sepLigne . 'Laurent TOGIER`§\`\`§`75006`PARIS'. $sepLigne . '§il a dit §§aie§§ ` en \\criant§'; $lignes = []; $regexp = sprintf( '#(?<![%1$s\\\])%1$s(?!%1$s)(?<data>.*?)(?<![%1$s\\\])%1$s(?<sep>[%2$s%3$s]|$)|(?<data>[^%2$s%3$s]*)(?<sep>[%2$s%3$s]|$)#Jus', $dlmtTxt, $sepChmp, $sepLigne ); if( preg_match_all($regexp, $chaines, $matches, PREG_SET_ORDER) ) { $ligne = []; foreach($matches as $match) { $ligne[] = stripslashes(str_replace(["\\$dlmtTxt", "$dlmtTxt$dlmtTxt"], $dlmtTxt, $match['data'])); if($match['sep'] !== $sepChmp && count(array_filter($ligne))) { $lignes[] = $ligne; $ligne = []; } } } var_dump($lignes);
Output for 7.1.25 - 7.1.33, 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 - 8.5.1
array(7) { [0]=> array(4) { [0]=> string(14) "Laurent TOGIER" [1]=> string(13) "19` Rue Bréa" [2]=> string(5) "75006" [3]=> string(5) "PARIS" } [1]=> array(4) { [0]=> string(14) "Laurent TOGIER" [1]=> string(11) "` Rue Bréa" [2]=> string(5) "75006" [3]=> string(5) "PARIS" } [2]=> array(4) { [0]=> string(14) "Laurent TOGIER" [1]=> string(3) "19`" [2]=> string(5) "75006" [3]=> string(5) "PARIS" } [3]=> array(4) { [0]=> string(14) "Laurent TOGIER" [1]=> string(1) "`" [2]=> string(5) "75006" [3]=> string(5) "PARIS" } [4]=> array(4) { [0]=> string(14) "Laurent TOGIER" [1]=> string(14) "19` Rue` Bréa" [2]=> string(5) "75006" [3]=> string(6) "PARIS " } [5]=> array(4) { [0]=> string(14) "Laurent TOGIER" [1]=> string(2) "``" [2]=> string(5) "75006" [3]=> string(5) "PARIS" } [6]=> array(1) { [0]=> string(28) "il a dit §aie§ ` en criant" } }
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:
172.99 ms | 408 KiB | 5 Q