Php retrieves data from xml-super simple-urgent data Source: www. caipiaokong. comapilotteryxml. php? Typessq needs to fetch the first three rows of data. php needs to fetch the data in xml. -- Super simple --- urgent
Data source: http://www.caipiaokong.com/api/lottery/xml.php? Type = ssq
The first three rows of data to be retrieved
Share:
------ Solution --------------------
$url = 'http://www.caipiaokong.com/api/lottery/xml.php?type=ssq';
$ar = file($url);
print_r(array_slice($ar, 2, 3));
Array
(
[0] =>
[1] =>
[2] =>
)
$url = 'http://www.caipiaokong.com/api/lottery/xml.php?type=ssq';
$xml = simplexml_load_file($url);
foreach($xml->row as $i=>$v) {
if($i > 2) break;
$res[] = current((array)$v->attributes());
}
print_r($res);
Array
(
[0] => Array
(
[CT] => 13113
[Opencode] =>
------ Solution --------------------
09
[Opentime] => 21:30:00
[Ballsnum] => 1
)
[1] => Array
(
[CT] => 13112
[Opencode] =>
------ Solution --------------------
07
[Opentime] => 21:30:00
[Ballsnum] => 1
)
[2] => Array
(
[CT] => 13111
[Opencode] => 01,02, 03,06, 08,33
------ Solution --------------------
13
[Opentime] => 21:30:00
[Ballsnum] => 1
)
[3] => Array
(
[CT] => 13110
[Opencode] => 15, 17, 18, 21, 29, 32
------ Solution --------------------
13
[Opentime] => 21:30:00
[Ballsnum] => 2
)
[4] => Array
(
[CT] => 13109
[Opencode] =>, 23, 24, 27, 29, 32
------ Solution --------------------
08
[Opentime] => 21:30:00
[Ballsnum] => 3
)
[5] => Array
(
[CT] => 13108
[Opencode] => 16, 21