基于ASP与Access数据库的网站开发,中英文的网站是怎么做的,墨鱼wordpress,做h5的网站的区别PHP抓取页面上的数组 并循环输出 急 在线等我用file_get_contents()抓取了 这个网址上的内容http://simonfenci.sinaapp.com/index.php?keysimonwd1314abc看似好像反回的是数组。。但是我不管怎么用foreach循环都报错。。我只想把数组中的word里面的值 取出来。。谁帮帮我…PHP抓取页面上的数组 并循环输出 急 在线等我用file_get_contents()抓取了 这个网址上的内容http://simonfenci.sinaapp.com/index.php?keysimonwd1314abc看似好像反回的是数组。。但是我不管怎么用foreach循环都报错。。我只想把数组中的word里面的值 取出来。。谁帮帮我啊急------解决思路----------------------$s file_get_contents(http://simonfenci.sinaapp.com/index.php?keysimonwd1314abc);preg_match_all(/\[word\] (.)/, $s, $m);print_r($m[1]);Array([0] 1314[1] abc)------解决思路----------------------$sfile_get_contents(http://simonfenci.sinaapp.com/index.php?keysimonwd1314abc);$rule#(?\[word\] )\s\w#;preg_match_all($rule,$s,$arr);print_r($arr);Array([0] Array([0] 1314[1] abc))------解决思路----------------------http://simonfenci.sinaapp.com/index.php?keysimonwd1314abc返回的是string(247) Array ( [0] Array ( [word] 1314 [word_tag] 90 [index] 0 ) [1] Array ( [word] abc [word_tag] 95 [index] 1 ) ) //一个数组结构的字符串而不是一个数组//编码$arr array(0array(word 1314,word_tag 90,index 0),1 Array(word abc,word_tag 95,index 1));echo( json_encode($arr) );//解码$arr array();$url http://simonfenci.sinaapp.com/index.php?keysimonwd1314abc;$ch curl_init();curl_setopt($ch, CURLOPT_URL, $url);curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);curl_setopt($ch, CURLOPT_HEADER, 0);$output curl_exec($ch);$arr json_decode($output,true);curl_close($ch);也可以用 serialize() 和 unserialize() 这个序列化函数 替换 json。------解决思路----------------------补充//json 返回的字符串[{word :1314,word_tag:90,index:0},{word:abc,word_tag:95,index:1}]//serialize 返回的字符串a:2:{i:0;a:3:{s:5:word ;i:1314;s:8:word_tag;i:90;s:5:index;i:0;}i:1;a:3:{s:4:word;s:3:abc;s:8:word_tag;i:95;s:5:index;i:1;}}明显比直接 var_export($val,true); 输出的更短并且可以轻易还原。相关文章相关视频