简体   繁体   中英

Display separated array-contents in separated lines

I'm working with the php sdk from Facbeook . 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):

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:

Pagname1, 1234567899011, Sitedescription

Pagename2, 1234567890, Description of the page

...

So i tried using different foreach variants, but i didn't get an useable result.

Does anyone know how i can realize this?

JavaScript:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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