3v4l.org

run code in 300+ PHP versions simultaneously
<?php $student_comment_new = 'PEwuSW50cm9kdWN0aW9uIC0gUGFnZSAyIG9mIDI+Zmlyc3QgY29tbWVudA=='; $fixed = base64_decode($student_comment_new); echo $fixed . "\n\n"; //Decode the entire comment $comment_cltxt = base64_decode($student_comment_new); echo $comment_cltxt . "\n\n"; //get the comment number. $comment_nr = explode('><L.', $comment_cltxt)[0]; $comment_nr = explode('<', $comment_nr)[1]; //get the comment end-text $comment_nr_string = '<' . $comment_nr . '>'; $comment_end_string = '<e.' . $comment_nr . '>'; echo $comment_nr . "\n"; echo $comment_nr_string . "\n"; echo $comment_end_string . "\n"; //get the comment text itself $pos1 = strlen($comment_nr_string); $pos2 = strlen($comment_end_string); $comment_text = substr($comment_cltxt, $pos1, -$pos2); echo $comment_text . "\n";
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 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.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
<L.Introduction - Page 2 of 2>first comment <L.Introduction - Page 2 of 2>first comment L.Introduction - Page 2 of 2>first comment <L.Introduction - Page 2 of 2>first comment> <e.L.Introduction - Page 2 of 2>first comment>
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 <L.Introduction - Page 2 of 2>first comment <L.Introduction - Page 2 of 2>first comment L.Introduction - Page 2 of 2>first comment <L.Introduction - Page 2 of 2>first comment> <e.L.Introduction - Page 2 of 2>first comment>

preferences:
195.41 ms | 402 KiB | 227 Q