3v4l.org

run code in 300+ PHP versions simultaneously
<?php $url='http://hogedatta.com/';//取得したいURL $html=file_get_contents($url);//htmlをゴソっと取得 mb_language('Japanese');//エンコードエラー対策 $html=mb_convert_encoding($html,'utf8','auto');//文字コードをUTF-8に変換 $html=preg_replace('/(\n|\r)/','',$html);//改行コードを全部消す preg_match_all('@\<div class=\"ranking\"\>(.*?)\<\/div\>@u',$html,$matches);//配列に入れる foreach($matches[0] as $match){ //順位 preg_match('@\<span class=\"num\"\>(.*)位\<\/span\> \<span class=\"product\"\>@u',$match,$num_moto); $num=$num_moto[1]; //商品名 preg_match('@\<span class=\"product\"\>(.*)\<\/span\> \<span class=\"price\"\>@u',$match,$product_moto); $product=$product_moto[1]; //価格 preg_match('@\<span class=\"price\"\>&yen;(.*)\<\/span\>\t\<p class=\"description\"\>@u',$match,$price_moto); $price=$price_moto[1]; //商品詳細 preg_match('@\<p class=\"description\"\>(.*)\<\/p\>\<\/div\>@u',$match,$description_moto); $description=$description_moto[1]; print '順位:'.$num.'<br />'; print '商品名:'.$product.'<br />'; print '価格:'.$price.'<br />'; print '商品詳細:'.$description.'<br /><br />'; } ?>
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for hogedatta.com failed: System error in /in/DnscN on line 4 Warning: file_get_contents(http://hogedatta.com/): Failed to open stream: php_network_getaddresses: getaddrinfo for hogedatta.com failed: System error in /in/DnscN on line 4
Output for 8.0.13 - 8.0.30
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/DnscN on line 4 Warning: file_get_contents(http://hogedatta.com/): Failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/DnscN on line 4
Output for 8.0.0 - 8.0.12
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/DnscN on line 4 Warning: file_get_contents(http://hogedatta.com/): Failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/DnscN on line 4
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.25, 7.3.0 - 7.3.12, 7.3.32 - 7.3.33, 7.4.0, 7.4.26 - 7.4.33
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: System error in /in/DnscN on line 4 Warning: file_get_contents(http://hogedatta.com/): failed to open stream: php_network_getaddresses: getaddrinfo failed: System error in /in/DnscN on line 4
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.25
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/DnscN on line 4 Warning: file_get_contents(http://hogedatta.com/): failed to open stream: php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /in/DnscN on line 4

preferences:
273.43 ms | 403 KiB | 370 Q