mardi 31 mai 2016

Access array of object in php [duplicate]

This question already has an answer here:

array(1) {
    ["categories"]=> array(2) {
        [0]=> array(1) {
            [0]=> object(stdClass)#233 (4) {
                ["categoryid"]=> string(2) "19"
                ["categoryname"]=> string(7) "Science"
                ["authorname"]=> string(7) "avinash"
                ["description"]=> string(7) "Science"
            }
        }
        [1]=> array(1) {
            [0]=> object(stdClass)#234 (4) {
                ["categoryid"]=> string(2) "21"
                ["categoryname"]=> string(20) "Recipies around the " 
                ["authorname"]=> string(7) "Kishore"
                ["description"]=> string(25) "Recipies around the World"
            } 
        }

    }
}

I am trying to access this string using foreach:

<?php  foreach($categories as $category){ ?>
<tr>
<td><?php echo $category->categoryid; ?></td>
<td><?php echo $category->categoryname; ?></td>
</tr>
 <?php  } ?>

Getting error:

Trying to get property of non-object..



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/280puA9
via IFTTT

Aucun commentaire:

Enregistrer un commentaire