使用以下代码显示我的Twitter个人资料中的朋友列表。我想一次只加载一个特定的数字,例如20,然后在底部为第1-2-3-4-5页的页面提供分页链接(但是,除以限制)
$xml = simplexml_load_string($rawxml);
foreach ($xml->id as $key => $value)
{
$profile = simplexml_load_file("https://twitter.com/users/$value");
$friendscreenname = $profile->{"screen_name"};
$profile_image_url = $profile->{"profile_image_url"};
echo "$friendscreenname
";
}
**更新****
if (!isset($_GET['i'])) {
$i = 0;
} else {
$i = (int) $_GET['i'];
}
$limit = $i + 10;
$rawxml = OauthGetFriends($consumerkey, $consumersecret, $credarray[0], $credarray[1]);
$xml = simplexml_load_string($rawxml);
foreach ($xml->id as $key => $value)
{
if ($i >= $limit) {
break;
}
$i++;
$profile = simplexml_load_file("https://twitter.com/users/$value");
$friendscreenname = $profile->{"screen_name"};
$profile_image_url = $profile->{"profile_image_url"};
echo "$friendscreenname
";
}
echo "Next 10
";
这项工作有效,只需要抵消从开始的输出即可$i。在想array_slice什么?