时间:2021-07-01 10:21:17 帮助过:43人阅读
function request_by_curl($remote_server, $post_string){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $remote_server); curl_setopt($ch, CURLOPT_POSTFIELDS, 'mypost=' . $post_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, "Jimmy's CURL Example beta"); $data = curl_exec($ch); curl_close($ch); return $data;}$string = request_by_curl("http://www.bwlc.net/bulletin/keno.html",80); $pat = '/\[\s\S]*?\ (.*?)\<\/td\>[\s\S]*?\ (.*?)\<\/td\>[\s\S]*?\ (.*?)\<\/td\>[\s\S]*?\ (.*?)\<\/td\>[\s\S]*?\<\/tr\>/i';preg_match_all($pat,$string,$outstr);foreach($outstr as $key => $value){ echo "第".$outstr[$key][1]."期,开奖结果为:".$outstr[$key][2]."飞盘:".$outstr[$key][3]."时间:".$outstr[$key][4]."\n";}
回复讨论(解决方案)
你把匹配结果数组的格式理解错了
foreach($outstr[0] as $key => $value){ echo "第".$outstr[1][$key]."期,开奖结果为:".$outstr[2][$key]."飞盘:".$outstr[3][$key]."时间:".$outstr[4][$key]."\n";}第712522期,开奖结果为:55,09,59,43,04,28,58,70,13,46,42,73,16,51,30,75,11,41,25,69飞盘:01时间:2015-08-20 23:55第712521期,开奖结果为:39,51,10,48,57,25,35,16,78,33,47,20,71,37,42,17,59,49,28,01飞盘:03时间:2015-08-20 23:50第712520期,开奖结果为:38,48,12,27,23,59,13,30,18,60,08,20,15,45,31,05,41,25,01,17飞盘:02时间:2015-08-20 23:45第712519期,开奖结果为:36,28,69,13,42,21,73,05,26,15,58,44,03,56,35,02,19,47,66,06飞盘:01时间:2015-08-20 23:40第712518期,开奖结果为:28,71,47,57,22,66,62,36,02,53,63,07,60,64,35,46,15,78,39,58飞盘:03时间:2015-08-20 23:35第712517期,开奖结果为:74,05,23,11,50,34,04,49,26,01,13,40,54,08,29,24,73,09,31,15飞盘:02时间:2015-08-20 23:30第712516期,开奖结果为:27,40,13,76,38,52,24,75,44,49,14,72,65,35,04,47,67,07,57,71飞盘:01时间:2015-08-20 23:25第712515期,开奖结果为:06,68,31,03,16,63,75,09,44,30,77,12,46,17,79,07,27,15,71,47飞盘:03时间:2015-08-20 23:20第712514期,开奖结果为:01,32,42,06,39,60,20,25,14,75,24,38,19,71,31,33,17,70,41,23飞盘:01时间:2015-08-20 23:15第712513期,开奖结果为:57,11,36,33,74,15,41,31,75,07,32,18,52,42,06,45,34,03,30,44飞盘:02时间:2015-08-20 23:10第712512期,开奖结果为:47,50,13,64,57,32,03,48,58,07,56,61,29,42,12,75,35,55,25,67飞盘:10时间:2015-08-20 23:05第712511期,开奖结果为:49,21,79,07,29,17,64,53,05,60,47,02,20,59,66,12,48,40,67,15飞盘:01时间:2015-08-20 23:00第712510期,开奖结果为:22,80,37,53,27,79,40,46,26,76,61,33,12,42,69,16,60,74,31,39飞盘:01时间:2015-08-20 22:55第712509期,开奖结果为:64,42,07,57,35,01,25,46,66,17,37,33,67,18,41,26,77,14,32,22飞盘:01时间:2015-08-20 22:50第712508期,开奖结果为:62,02,55,63,16,25,06,73,22,52,08,72,27,42,07,71,61,18,01,32飞盘:01时间:2015-08-20 22:45第712507期,开奖结果为:34,64,74,17,55,47,78,21,59,36,79,16,40,29,72,61,15,68,51,13飞盘:02时间:2015-08-20 22:40第712506期,开奖结果为:23,70,67,37,04,57,68,18,66,69,33,46,19,77,45,64,28,75,48,62飞盘:01时间:2015-08-20 22:35第712505期,开奖结果为:58,20,43,27,59,17,31,21,54,44,15,46,39,11,24,45,57,19,41,35飞盘:03时间:2015-08-20 22:30第712504期,开奖结果为:29,53,14,72,42,50,12,71,61,26,03,45,65,05,59,68,23,32,09,74飞盘:02时间:2015-08-20 22:25第712503期,开奖结果为:29,20,67,45,10,50,34,09,22,46,74,14,35,31,77,15,38,28,79,13飞盘:01时间:2015-08-20 22:20第712502期,开奖结果为:49,60,19,30,07,76,27,45,17,70,37,44,11,61,56,21,05,38,58,06飞盘:03时间:2015-08-20 22:15第712501期,开奖结果为:39,04,26,57,65,17,41,36,68,21,43,32,76,12,34,22,64,54,06,60飞盘:02时间:2015-08-20 23:55第712500期,开奖结果为:56,26,02,41,58,05,50,63,22,31,07,72,27,48,18,68,39,46,10,65飞盘:02时间:2015-08-20 22:05第712499期,开奖结果为:50,15,74,63,28,08,45,67,09,54,72,25,43,14,80,31,53,21,76,44飞盘:02时间:2015-08-20 22:00第712498期,开奖结果为:10,52,29,79,03,37,12,62,55,02,58,45,01,21,57,66,08,47,39,78飞盘:04时间:2015-08-20 21:55第712497期,开奖结果为:77,30,49,13,72,36,46,12,70,56,22,03,43,61,05,55,65,18,35,08飞盘:03时间:2015-08-20 21:50第712496期,开奖结果为:15,48,41,06,46,29,02,16,45,49,10,39,27,56,13,40,22,66,09,24飞盘:01时间:2015-08-20 21:45第712495期,开奖结果为:02,41,71,19,25,07,80,24,38,13,79,26,30,11,77,43,20,01,29,50飞盘:04时间:2015-08-20 21:40第712494期,开奖结果为:06,30,66,72,09,50,41,75,14,52,32,76,08,34,18,71,61,07,68,42飞盘:02时间:2015-08-20 21:35第712493期,开奖结果为:78,72,31,08,61,74,13,69,77,28,52,16,80,46,67,26,79,59,63,23飞盘:04时间:2015-08-20 21:30人气教程排行
- 174次 1 php如何获取跳转前的url
- 174次 2 php格林威治时间转换成当前时间的方法
- 174次 3 为什么php不能做大型系统?
- 174次 4 range函数怎么用
- 174次 5 php中计算页面加载时间几种方法总结_PHP教程
- 174次 6 求帮助,关于paypal支付返回值修改订单状态
- 174次 7 typecho怎么配置文章内容页?
- 174次 8 PhpStorm左侧structure不显示文件的方法列表是这么回事?
- 174次 9 查看PHP的环境变量_PHP
- 174次 10 PHP Primary script unknown 解决方法总结
- 174次 11 php的命名空间与自动加载实现方法
- 174次 12 解决laravel 出现ajax请求419(unknown status)的问题
- 173次 13 php 如何删除mysql记录
- 173次 14 PHP如何替换数组中的指定元素
- 173次 15 怎么去除字符串中非汉字、非字母、非数字的字符
- 173次 16 mysql如何一次执行多条SQL语句
- 173次 17 修改header里面的Connection为close解决方法
- 173次 18 PHP基于session.upload_progress 实现文件上传进度显示功能详解
- 173次 19 php5.6.x到php7.0.x特性小结
- 172次 20 php为什么会出现504错误