0

My Array

Array ( 
    [0] => stdClass Object ( 
        [name] => name
        [title] => -- 
        [description] => No
        [url] => http://google.com
        [updated] => 1553419890 ) 
    [1] => stdClass Object ( 
        [name] => Hey
        [title] => Title
        [description] => Yes
        [url] =>  http://twitter.com
        [updated] => 1553321131 ) 
)

How do I loop the above array with for each?

1
  • what are you trying to achieve? Commented Apr 30, 2019 at 8:13

2 Answers 2

0

//for an array in array

foreach(name_of_your_array as array) { data = array["name"]; }

//for an object in your array

foreach(name_of_your_array as array) { data = array->name; } an example of how you can do

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

Comments

0

I think you are looking for how to loop through the array using key-value pair format

foreach($name_of_your_records_array As $key => $ object)
{
    $count_of_record = $key;
    $name = $object->name;
    $title = $object->title;
    //...
}

Reference link :

PHP manual foreach

Accessing object inside an array PHP

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.