3v4l.org

run code in 300+ PHP versions simultaneously
<?php $doc = new DOMDocument; // We don't want to bother with white spaces $doc->preserveWhiteSpace = false; $doc->strictErrorChecking = false; $doc->recover = true; $doc->loadHTMLFile('https://www.bloomberg.com/quote/USDJPY:CUR'); $xpath = new DOMXPath($doc); $query = "//meta[@itemprop='priceChangePercent']"; $entries = $xpath->query($query); foreach ($entries as $entry) { $result = trim($entry->getAttribute('content')); $ret_ = explode(' ', $result); //make sure every element in the array don't start or end with blank foreach ($ret_ as $key=>$val){ $ret_[$key]=trim($val); } //delete the empty element and the element is blank "\n" "\r" "\t" //I modify this line $ret_ = array_values(array_filter($ret_,deleteBlankInArray)); //echo the last element echo $ret_[0]; } ?>
Output for 7.1.20 - 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.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Warning: DOMDocument::loadHTMLFile(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/HRh4h on line 11 Warning: DOMDocument::loadHTMLFile(): I/O warning : failed to load external entity "https://www.bloomberg.com/quote/USDJPY:CUR" in /in/HRh4h on line 11
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 Warning: DOMDocument::loadHTMLFile(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /in/HRh4h on line 11 Warning: DOMDocument::loadHTMLFile(): I/O warning : failed to load external entity "https://www.bloomberg.com/quote/USDJPY:CUR" in /in/HRh4h on line 11
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7
Warning: DOMDocument::loadHTMLFile(): php_network_getaddresses: getaddrinfo failed: System error in /in/HRh4h on line 11 Warning: DOMDocument::loadHTMLFile(https://www.bloomberg.com/quote/USDJPY:CUR): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/HRh4h on line 11 Warning: DOMDocument::loadHTMLFile(): I/O warning : failed to load external entity "https://www.bloomberg.com/quote/USDJPY:CUR" in /in/HRh4h on line 11

preferences:
179.98 ms | 402 KiB | 218 Q