3v4l.org

run code in 300+ PHP versions simultaneously
<?php $posts['Author1'] = ['sdsadsad daSDA DDASd asd aSD Sd dA SD ASD sadasdasds sadasd @jhsad.sadas.com sdsdADSA sada', 'KDJKLFFD GFDGFDHGF GFHGFDHGFH GFHFGH Lklfgfd gdfsgfdsg df gfdhgf g hfghghjh jhg @jhsad.sadas.com sfgff fsdfdsf', 'jhjkfsdg fdgdf sfds hgfj j kkjjfghgkjf hdkjtkj lfdjfg hkgfl @jhsad.sadas.com dsfjdshflkds kg lsfdkg;fdgl']; $posts['Author2']=['This is some random string representative of non-signature text. This is the *author\'s* signature.', 'Different message body text. This is the *author\'s* signature. This is an afterthought that expresses that a signature is not always at the end.', 'Finally, this is unwanted stuff. This is the *author\'s* signature.']; foreach ($posts as $author => $texts) { echo "Author: $author\n"; usort($texts, function($a, $b) { return strlen($a) <=> strlen($b); // sort ASC by strlen; mb_strlen probably isn't advantageous }); var_export($texts); echo "\n"; foreach ($texts as $index => $string) { if (!$index) { $overlaps = preg_split('/\s+/', $string, 0, PREG_SPLIT_NO_EMPTY); // declare with all non-white-space substrings from first text } else { $overlaps = array_intersect($overlaps, preg_split('/\s+/', $string, 0, PREG_SPLIT_NO_EMPTY)); // filter word bank using narrowing number of words } } var_export($overlaps); echo "\n"; // batch consecutive substrings $group = null; $consecutives = []; // clear previous iteration's data foreach ($overlaps as $i => $word) { if ($group === null || $i - $last > 1) { $group = $i; } $last = $i; $consecutives[$group][] = $word; } var_export($consecutives); echo "\n"; foreach ($consecutives as $words) { // match potential signatures in first text for measurement: if (preg_match_all('/\Q' . implode('\E\s+\Q', $words) . '\E/', $texts[0], $out)) { // make alternatives characters literal using \Q & \E $potential_signatures = $out[0]; } } usort($potential_signatures, function($a, $b){ return strlen($b) <=> strlen($a); // sort DESC by strlen; mb_strlen probably isn't advantageous }); echo "Assumed Signature: {$potential_signatures[0]}\n\n"; }
Output for 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.4, 8.3.6 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
Author: Author1 array ( 0 => 'sdsadsad daSDA DDASd asd aSD Sd dA SD ASD sadasdasds sadasd @jhsad.sadas.com sdsdADSA sada', 1 => 'jhjkfsdg fdgdf sfds hgfj j kkjjfghgkjf hdkjtkj lfdjfg hkgfl @jhsad.sadas.com dsfjdshflkds kg lsfdkg;fdgl', 2 => 'KDJKLFFD GFDGFDHGF GFHGFDHGFH GFHFGH Lklfgfd gdfsgfdsg df gfdhgf g hfghghjh jhg @jhsad.sadas.com sfgff fsdfdsf', ) array ( 11 => '@jhsad.sadas.com', ) array ( 11 => array ( 0 => '@jhsad.sadas.com', ), ) Assumed Signature: @jhsad.sadas.com Author: Author2 array ( 0 => 'Finally, this is unwanted stuff. This is the *author\'s* signature.', 1 => 'This is some random string representative of non-signature text. This is the *author\'s* signature.', 2 => 'Different message body text. This is the *author\'s* signature. This is an afterthought that expresses that a signature is not always at the end.', ) array ( 2 => 'is', 5 => 'This', 6 => 'is', 7 => 'the', 8 => '*author\'s*', 9 => 'signature.', ) array ( 2 => array ( 0 => 'is', ), 5 => array ( 0 => 'This', 1 => 'is', 2 => 'the', 3 => '*author\'s*', 4 => 'signature.', ), ) Assumed Signature: This is the *author's* signature.
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.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Author: Author1 array ( 0 => 'sdsadsad daSDA DDASd asd aSD Sd dA SD ASD sadasdasds sadasd @jhsad.sadas.com sdsdADSA sada', 1 => 'jhjkfsdg fdgdf sfds hgfj j kkjjfghgkjf hdkjtkj lfdjfg hkgfl @jhsad.sadas.com dsfjdshflkds kg lsfdkg;fdgl', 2 => 'KDJKLFFD GFDGFDHGF GFHGFDHGFH GFHFGH Lklfgfd gdfsgfdsg df gfdhgf g hfghghjh jhg @jhsad.sadas.com sfgff fsdfdsf', ) array ( 11 => '@jhsad.sadas.com', ) array ( 11 => array ( 0 => '@jhsad.sadas.com', ), ) Assumed Signature: @jhsad.sadas.com Author: Author2 array ( 0 => 'Finally, this is unwanted stuff. This is the *author\'s* signature.', 1 => 'This is some random string representative of non-signature text. This is the *author\'s* signature.', 2 => 'Different message body text. This is the *author\'s* signature. This is an afterthought that expresses that a signature is not always at the end.', ) array ( 2 => 'is', 5 => 'This', 6 => 'is', 7 => 'the', 8 => '*author\'s*', 9 => 'signature.', ) array ( 2 => array ( 0 => 'is', ), 5 => array ( 0 => 'This', 1 => 'is', 2 => 'the', 3 => '*author\'s*', 4 => 'signature.', ), ) Assumed Signature: This is the *author's* signature.

preferences:
171.6 ms | 415 KiB | 5 Q