Php retrieves xml data-super simple-in a hurry

Source: Internet
Author: User
Php take xml data -- super simple --- urgent data source: http://www.caipiaokong.com/api/lottery/xml.php? Type = ssq
The first three rows of data to be retrieved


Reply to discussion (solution)

Answer, close the post immediately, online, etc.

$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] =>, | 09
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[1] => Array
(
[CT] => 13112
[Opencode] =>, | 07
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[2] => Array
(
[CT] => 13111
[Opencode] => 01,02, 03,06, 08,33 | 13
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[3] => Array
(
[CT] => 13110
[Opencode] => 15, 17, 18, 21, 29, 32 | 13
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[4] => Array
(
[CT] => 13109
[Opencode] =>, 23, 24, 27, 29,32 | 08
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[5] => Array
(
[CT] => 13108
[Opencode] => 16, 21, | 05
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[6] => Array
(
[CT] => 13107
[Opencode] =>, | 11
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[7] => Array
(
[CT] => 13106
[Opencode] =>, 30, | 06
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[8] => Array
(
[CT] => 13105
[Opencode] =>, | 09
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[9] => Array
(
[CT] => 13104
[Opencode] => 01,02, 04,15, 17,28 | 11
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[10] => Array
(
[CT] => 13103
[Opencode] =>, | 07
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[11] => Array
(
[CT] => 13102
[Opencode] =>, 06, | 03
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[12] => Array
(
[CT] => 13101
[Opencode] =>, | 01
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[13] => Array
(
[CT] => 13100
[Opencode] =>, | 11
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[14] => Array
(
[CT] => 13099
[Opencode] =>, | 03
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[15] => Array
(
[CT] => 13098
[Opencode] =>, | 14
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[16] => Array
(
[CT] => 13097
[Opencode] =>, | 07
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[17] => Array
(
[CT] => 13096
[Opencode] =>, | 15
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[18] => Array
(
[CT] => 13095
[Opencode] => 01,06, 15,19, 28,29 | 10
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[19] => Array
(
[CT] => 13094
[Opencode] =>, | 07
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[20] => Array
(
[CT] => 13093
[Opencode] =>, | 14
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[21] => Array
(
[CT] => 13092
[Opencode] => 07,11, 15,21, 26,31 | 06
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[22] => Array
(
[CT] => 13091
[Opencode] =>, | 10
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[23] => Array
(
[CT] => 13090
[Opencode] =>, | 08
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[24] => Array
(
[CT] => 13089
[Opencode] =>, | 13
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[25] => Array
(
[CT] => 13088
[Opencode] =>, 20, 21, | 14
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[26] => Array
(
[CT] => 13087
[Opencode] =>, | 05
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[27] => Array
(
[CT] => 13086
[Opencode] =>, | 11
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[28] => Array
(
[CT] => 13085
[Opencode] =>, | 16
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[29] => Array
(
[CT] => 13084
[Opencode] =>, | 03
[Opentime] => 21:30:00
[Ballsnum] => 2
)

)

$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] =>, | 09
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[1] => Array
(
[CT] => 13112
[Opencode] =>, | 07
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[2] => Array
(
[CT] => 13111
[Opencode] => 01,02, 03,06, 08,33 | 13
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[3] => Array
(
[CT] => 13110
[Opencode] => 15, 17, 18, 21, 29, 32 | 13
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[4] => Array
(
[CT] => 13109
[Opencode] =>, 23, 24, 27, 29,32 | 08
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[5] => Array
(
[CT] => 13108
[Opencode] => 16, 21, | 05
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[6] => Array
(
[CT] => 13107
[Opencode] =>, | 11
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[7] => Array
(
[CT] => 13106
[Opencode] =>, 30, | 06
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[8] => Array
(
[CT] => 13105
[Opencode] =>, | 09
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[9] => Array
(
[CT] => 13104
[Opencode] => 01,02, 04,15, 17,28 | 11
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[10] => Array
(
[CT] => 13103
[Opencode] =>, | 07
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[11] => Array
(
[CT] => 13102
[Opencode] =>, 06, | 03
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[12] => Array
(
[CT] => 13101
[Opencode] =>, | 01
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[13] => Array
(
[CT] => 13100
[Opencode] =>, | 11
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[14] => Array
(
[CT] => 13099
[Opencode] =>, | 03
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[15] => Array
(
[CT] => 13098
[Opencode] =>, | 14
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[16] => Array
(
[CT] => 13097
[Opencode] =>, | 07
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[17] => Array
(
[CT] => 13096
[Opencode] =>, | 15
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[18] => Array
(
[CT] => 13095
[Opencode] => 01,06, 15,19, 28,29 | 10
[Opentime] => 21:30:00
[Ballsnum] => 1
)

[19] => Array
(
[CT] => 13094
[Opencode] =>, | 07
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[20] => Array
(
[CT] => 13093
[Opencode] =>, | 14
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[21] => Array
(
[CT] => 13092
[Opencode] => 07,11, 15,21, 26,31 | 06
[Opentime] => 21:30:00
[Ballsnum] => 2
)

[22] => Array
(
[CT] => 13091
[Opencode] =>, | 10
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[23] => Array
(
[CT] => 13090
[Opencode] =>, | 08
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[24] => Array
(
[CT] => 13089
[Opencode] =>, | 13
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[25] => Array
(
[CT] => 13088
[Opencode] =>, 20, 21, | 14
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[26] => Array
(
[CT] => 13087
[Opencode] =>, | 05
[Opentime] => 21:30:00
[Ballsnum] => 3
)

[27] => Array
(
[CT] => 13086
[Opencode] =>, | 11
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[28] => Array
(
[CT] => 13085
[Opencode] =>, | 16
[Opentime] => 21:30:00
[Ballsnum] => 4
)

[29] => Array
(
[CT] => 13084
[Opencode] =>, | 03
[Opentime] => 21:30:00
[Ballsnum] => 2
)

) This is not very good. I want the content of the first three issues and can extract specific data, such as the date number, number, and time of the award.

1. date:
Number:
Time:
2. date:
Number:
Time:
3. period:
Number:
Time:
The above

Yes. you can change the second one by yourself. thank you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.