3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php foreach ($_FILES as $file) { // array of valid extensions $validExtensions = array('.jpg', '.jpeg', '.gif', '.png'); // get extension of the uploaded file $fileExtension = strrchr($file['name'], "."); // check if file Extension is on the list of allowed ones if (in_array($fileExtension, $validExtensions)) { $newNamePrefix = time() . '_'; save('uploads/' . $newNamePrefix . $file['name']); echo 'Done ...'; } else { echo 'You must upload an image...'; } } ?>
Output for 4.3.0 - 5.6.25, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0