1
for(int $i=0; $i<count($lists["item_collection"]["entries"]); $i++){
        foreach($lists['item_collection']['entries'] as $list) 
        {
            $print['file_name'] = $list[$i]['name'];
            $print['file_id'] = $list[$i]['id'];
            $print['file_type'] = $list[$i]['type'];

            array_push($content,$print);
        }
    }

i am trying to get the name,type,id of the file array but i only get the first one so i tried to for loop it but it doesn't work. am i doing this right?

2
  • Just to be clear, what language is this? PHP, correct? Commented Mar 7, 2015 at 8:28
  • Please try to use the yield keyword and a generating method. Commented Aug 25, 2015 at 19:45

2 Answers 2

1

I do not tested it

foreach($lists["item_collection"]["entries"] as $v){
     foreach($v as $val){  
         $print['file_name'] = $val['name'];
        $print['file_id'] = $val['id'];
        $print['file_type'] = $val['type'];
        array_push($content,$print);
     }

}
Sign up to request clarification or add additional context in comments.

Comments

0

No need to do it inside a for loop, just:

foreach($lists["item_collection"]["entries"] as $key => $val){

    $print['file_name'] = $val['name'];
    $print['file_id'] = $val['id'];
    $print['file_type'] = $val['type'];

    array_push($content,$print);

}

1 Comment

welcome, I up vote your question. keep posting! Cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.