相关疑难解决方法(0)

如何使用PHP在foreach循环中分隔行

使用以下代码显示我的推特个人资料中的朋友列表.我喜欢一次只加载一定数量,比如说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 "<a href=$profile_image_url>$friendscreenname</a><br>";
}
Run Code Online (Sandbox Code Playgroud)

******更新******

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 "<a href=$profile_image_url>$friendscreenname</a><br>"; …
Run Code Online (Sandbox Code Playgroud)

php pagination simplexml

4
推荐指数
1
解决办法
6489
查看次数

标签 统计

pagination ×1

php ×1

simplexml ×1