php 取xml中的数据 --超级简单---急急
数据源:http://www.caipiaokong.com/api/lottery/xml.php?type=ssq
要取它的前3行数据
[解决办法]
$url = 'http://www.caipiaokong.com/api/lottery/xml.php?type=ssq';Array
$ar = file($url);
print_r(array_slice($ar, 2, 3));
$url = 'http://www.caipiaokong.com/api/lottery/xml.php?type=ssq';Array
$xml = simplexml_load_file($url);
foreach($xml->row as $i=>$v) {
if($i > 2) break;
$res[] = current((array)$v->attributes());
}
print_r($res);
[解决办法]
05
[opentime] => 2013-09-15 21:30:00
[ballsnum] => 2
)
[6] => Array
(
[expect] => 13107
[opencode] => 07,09,11,17,28,31
[解决办法]
11
[opentime] => 2013-09-12 21:30:00
[ballsnum] => 3
)
[7] => Array
(
[expect] => 13106
[opencode] => 09,11,23,30,31,32
[解决办法]
06
[opentime] => 2013-09-10 21:30:00
[ballsnum] => 3
)
[8] => Array
(
[expect] => 13105
[opencode] => 01,11,23,27,31,32
[解决办法]
09
[opentime] => 2013-09-08 21:30:00
[ballsnum] => 4
)
[9] => Array
(
[expect] => 13104
[opencode] => 01,02,04,15,17,28
[解决办法]
11
[opentime] => 2013-09-05 21:30:00
[ballsnum] => 1
)
[10] => Array
(
[expect] => 13103
[opencode] => 02,04,09,13,18,20
[解决办法]
07
[opentime] => 2013-09-03 21:30:00
[ballsnum] => 3
)
[11] => Array
(
[expect] => 13102
[opencode] => 02,04,05,06,08,16
[解决办法]
03
[opentime] => 2013-09-01 21:30:00
[ballsnum] => 2
)
[12] => Array
(
[expect] => 13101
[opencode] => 05,07,09,23,27,32
[解决办法]
01
[opentime] => 2013-08-29 21:30:00
[ballsnum] => 3
)
[13] => Array
(
[expect] => 13100
[opencode] => 04,08,11,14,16,20
[解决办法]
11
[opentime] => 2013-08-27 21:30:00
[ballsnum] => 3
)
[14] => Array
(
[expect] => 13099
[opencode] => 05,11,20,21,26,31
[解决办法]
03
[opentime] => 2013-08-25 21:30:00
[ballsnum] => 1
)
[15] => Array
(
[expect] => 13098
[opencode] => 07,15,18,19,20,26
[解决办法]
14
[opentime] => 2013-08-22 21:30:00
[ballsnum] => 2
)
[16] => Array
(
[expect] => 13097
[opencode] => 05,14,17,22,23,25
[解决办法]
07
[opentime] => 2013-08-20 21:30:00
[ballsnum] => 2
)
[17] => Array
(
[expect] => 13096
[opencode] => 01,02,22,28,29,30
[解决办法]
15
[opentime] => 2013-08-18 21:30:00
[ballsnum] => 4
)
[18] => Array
(
[expect] => 13095
[opencode] => 01,06,15,19,28,29
[解决办法]
10
[opentime] => 2013-08-15 21:30:00
[ballsnum] => 1
)
[19] => Array
(
[expect] => 13094
[opencode] => 02,04,14,18,20,22
[解决办法]
07
[opentime] => 2013-08-13 21:30:00
[ballsnum] => 3
)
[20] => Array
(
[expect] => 13093
[opencode] => 01,02,08,26,29,31
[解决办法]
14
[opentime] => 2013-08-11 21:30:00
[ballsnum] => 4
)
[21] => Array
(
[expect] => 13092
[opencode] => 07,11,15,21,26,31
[解决办法]
06
[opentime] => 2013-08-08 21:30:00
[ballsnum] => 2
)
[22] => Array
(
[expect] => 13091
[opencode] => 04,14,24,25,28,31
[解决办法]
10
[opentime] => 2013-08-06 21:30:00
[ballsnum] => 4
)
[23] => Array
(
[expect] => 13090
[opencode] => 02,05,11,23,24,29
[解决办法]
08
[opentime] => 2013-08-04 21:30:00
[ballsnum] => 4
)
[24] => Array
(
[expect] => 13089
[opencode] => 04,08,12,19,21,25
[解决办法]
13
[opentime] => 2013-08-01 21:30:00
[ballsnum] => 4
)
[25] => Array
(
[expect] => 13088
[opencode] => 09,15,20,21,22,24
[解决办法]
14
[opentime] => 2013-07-30 21:30:00
[ballsnum] => 3
)
[26] => Array
(
[expect] => 13087
[opencode] => 02,13,19,23,24,28
[解决办法]
05
[opentime] => 2013-07-28 21:30:00
[ballsnum] => 3
)
[27] => Array
(
[expect] => 13086
[opencode] => 02,04,11,13,16,26
[解决办法]
11
[opentime] => 2013-07-25 21:30:00
[ballsnum] => 4
)
[28] => Array
(
[expect] => 13085
[opencode] => 02,08,12,14,16,32
[解决办法]
16
[opentime] => 2013-07-23 21:30:00
[ballsnum] => 4
)
[29] => Array
(
[expect] => 13084
[opencode] => 05,07,09,11,20,21
[解决办法]
03
[opentime] => 2013-07-21 21:30:00
[ballsnum] => 2
)
)