简体   繁体   English

在分隔行中显示分隔的数组内容

[英]Display separated array-contents in separated lines

I'm working with the php sdk from Facbeook .我正在使用Facbeook的 php sdk So i'd like to give out pages which the user is admin of.所以我想给出用户管理的页面。 I'd decoded the json string to archieve an array (had already removed the "['data']"-key):我解码了 json 字符串以归档一个数组(已经删除了“['data']”-key):

Array (
    [0] => Array
        (
            [name] => Pagename1
            [id] => 1234567899011
            [about] => Sitedescription.
        )
    [1] => Array
    (
            [name] => Pagename2
            [id] => 1234567890
            [about] => Description of the page.
     )
 )

So, as you can see, i got an array which is seperated with int's from 0 upt to X. What i'd like to have is that i can output these values foreach array in one line like this example:所以,你可以看到,我得到的是从0到UPT十,我想什么有分隔为int的数组是我可以输出这些值的foreach数组中像这样的例子一行:

Pagname1, 1234567899011, Sitedescription

Pagename2, 1234567890, Description of the page

...

So i tried using different foreach variants, but i didn't get an useable result.所以我尝试使用不同的 foreach 变体,但我没有得到可用的结果。

Does anyone know how i can realize this?有谁知道我怎么能意识到这一点?

JavaScript: JavaScript:

for (var i = 0, count = yourArray.length; i < count; i++ {
    console.log(yourArray[i].name + ', ' + yourArray[i].id + ', ' + yourArray[i].about);
}

PHP: PHP:

for ($i = 0, $count = count($yourArray); $i < $count; $i++ {
    echo $yourArray[$i]['name'] . ', ' . $yourArray[$i]['id'] . ', ' . $yourArray[$i]['about'] . "\n";
}

Not tested, but you should get the idea.没有经过测试,但你应该明白了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM