3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $X = array ( 'ALLUSERSPROFILE' => '', 'APPDATA' => '', 'COMMANDER_DRIVE' => '', 'COMMANDER_EXE' => '', 'COMMANDER_INI' => '', 'COMMANDER_PATH' => '', 'CommonProgramFiles' => '', 'CommonProgramFiles(x86)' => '', 'CommonProgramW6432' => '', 'COMPUTERNAME' => '', 'ComSpec' => '', 'EMAIL' => '', 'FP_NO_HOST_CHECK' => '', 'HOMEDRIVE' => '', 'HOMEPATH' => '', 'LOCALAPPDATA' => '', 'LOGONSERVER' => '', 'NUMBER_OF_PROCESSORS' => '', 'OS' => '', 'Path' => '', 'PATHEXT' => '', 'PROCESSOR_ARCHITECTURE' => '', 'PROCESSOR_ARCHITEW6432' => '', 'PROCESSOR_IDENTIFIER' => '', 'PROCESSOR_LEVEL' => '', 'PROCESSOR_REVISION' => '', 'ProgramData' => '', 'ProgramFiles' => '', 'ProgramFiles(x86)' => '', 'ProgramW6432' => '', 'PROMPT' => '', 'PSModulePath' => '', 'PUBLIC' => '', 'SESSIONNAME' => '', 'SystemDrive' => '', 'SystemRoot' => '', 'TEMP' => '', 'TMP' => '', 'USERDOMAIN' => '', 'USERDOMAIN_ROAMINGPROFILE' => '', 'USERNAME' => '', 'USERPROFILE' => '', 'VBOX_INSTALL_PATH' => '', 'VBOX_MSI_INSTALL_PATH' => '', 'windir' => '', 'HTTP_COOKIE' => '', 'HTTP_ACCEPT_LANGUAGE' => '', 'HTTP_ACCEPT_ENCODING' => '', 'HTTP_REFERER' => '', 'HTTP_USER_AGENT' => '', 'HTTP_ACCEPT' => '', 'HTTP_CACHE_CONTROL' => '', 'HTTP_CONNECTION' => '', 'HTTP_HOST' => '', 'SCRIPT_FILENAME' => '', 'REDIRECT_STATUS' => '', 'SERVER_NAME' => '', 'SERVER_PORT' => '', 'SERVER_ADDR' => '', 'REMOTE_PORT' => '', 'REMOTE_ADDR' => '', 'SERVER_SOFTWARE' => '', 'GATEWAY_INTERFACE' => '', 'SERVER_PROTOCOL' => '', 'DOCUMENT_ROOT' => '', 'DOCUMENT_URI' => '', 'REQUEST_URI' => '', 'SCRIPT_NAME' => '', 'CONTENT_LENGTH' => '', 'CONTENT_TYPE' => '', 'REQUEST_METHOD' => '', 'QUERY_STRING' => '', 'FCGI_ROLE' => '', 'PHP_SELF' => '', 'REQUEST_TIME_FLOAT' => '', 'REQUEST_TIME' => '', ); $time = microtime(true); for ($i = 0; $i < 10000; $i++) { $array = []; $str = '|' . implode('|', array_keys($X)); do { if (false !== $pos = strpos($str, '|HTTP_')) { if (false !== $pos2 = strpos($str, '|', $pos + 1)) { $len = $pos2 - $pos - 1; } else { $len = null; } $array[] = substr($str, $pos + 1, $len); $str = $pos2 !== false ? substr($str, $pos2) : ''; } } while ($pos !== false && $str); } //var_dump($X, count($X), $array, microtime(true) - $time);
based on sPqde
Output for 5.4.0 - 7.1.0
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/1nu2t on line 85
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/1nu2t on line 85
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/1nu2t on line 85
Process exited with code 255.