PHP
·
发表于 5年以前
·
阅读量:8296
*ÓÃfile_get_contents()ץȡÁË Õa¸oÍøÖÉϵÄÄÚÈÝ**
http://simonfenci.sinaapp.com/index.php?key=simon&wd;=1314abc
¿´ËƺÃÏñ´»ØµÄÊÇÊý×e¡£¡£µ«ÊÇÎÒ²»¹ÜÔoôÓÃforeachÑ»¶¼±¨´i¡£¡£
ÎÒÖ»Ïe°ÑÊý×eÖеÄwordÀiÃaeµÄÖµ È¡³oÀ´¡£
½¨ÈçÏ£ºÕý½a£¨ÆaËuµÄ×Ö¶ÎÒ»Ñu£¬°ÑwordÌae»»¼´¿É£(C)
$s=file_get_contents('http://simonfenci.sinaapp.com/index.php?key=simon&wd;=1314abc');$rule='#(?<=\[word\] =>)\s\w+#';preg_match_all($rule,$s,$arr);print_r($arr);
ÎÒµÄÓoµ½µÄÎÊÌaÈçÏ£º
<?php
@header('content-type:text/html;charset=utf-8');
function show_bug($msg){
echo "<pre>";
print_r($msg);
echo "</pre>";
}
//ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)');
//$url="http://redhatcn.cn//Home/Login/mmzh2/t/user";
// ËuÓÐ[jb] => ºoÃaeµÄ½ð¶i£¬ËuÓнð¶iÏa¼Ó
$url='array.txt';
$s=file_get_contents($url);
$rule='#(?<=\[jb\] =>)\s\w+#';preg_match_all($rule,$s,$arr);
// $bool=is_array($arr);
// var_dump($bool);
//show_bug($arr);
$arr_num=$arr[0];
//array_sumº¯Êý*µ»ØÊý×eÖÐËuÓÐÖµµÄ×ܺ͡£
echo 'ÎļþÖÐËuÓÐjbÖ®ºÍΪ£º'.array_sum($arr_num);
?>
array.txtÄÚÈÝÈçÏÂËuʾ£º
Array( [0] => Array ( [id] => 183 [cf] => 0 [date] => 2016-08-26 21:17:32 [zffs1] => 0 [zffs2] => 1 [zffs3] => 0 [jb] => 5000 [zt] => 1 [user] => 18676081117 [qr_zt] => 1 [user_tjr] => 18943636615 [user_nc] => ¿ÉÀÖ [cf_ds] => 0 [jycg_ds] => 0 [yid] => [ok] => 1 ) [1] => Array ( [id] => 240 [cf] => 0 [date] => 2016-09-03 12:06:50 [zffs1] => 1 [zffs2] => 1 [zffs3] => 1 [jb] => 8000 [zt] => 0 [user] => 15192777617 [qr_zt] => 0 [user_tjr] => 13987611435 [user_nc] => Ö¨¬½¡§¸Û [cf_ds] => 0 [jycg_ds] => 0 [yid] => [ok] => 1 ) )
ÒÔÉÏÕaƪphp file_get_contentsÈ¡ÎļþÖÐÊý×eÔªËصĽ¨¾ÍÊÇС±a*ÖÏi¸ø´o¼ÒµÄÈ«²¿ÄÚÈÝÁË£¬Ï£ÍuÄܸø´o¼ÒÒ»¸o²Î¿¼£¬Ò²Ï£Íu´o¼Ò¶a¶aÖ§³Ö½Å±¾Ö®¼Ò¡£