I'm trying to retrieve articles from a particular category to display it as a part of some module located on the homepage. So I set states for model and retrieved the items via:

$items = $model->getItems();

then I did a var_dump:

foreach ( $items as $item ) {

  var_dump( $item );


And here is what I find strange (var_dump excerpt):


["images"]=> string(202) "{"image_intro":"images\/slider\/slider_02.jpg","float_intro":"","image_intro_alt":"","image_intro_caption":"","image_fulltext":"","float_fulltext":"","image_fulltext_alt":"","image_fulltext_caption":""}" ["urls"]=> string(121) "{"urla":false,"urlatext":"","targeta":"","urlb":false,"urlbtext":"","targetb":"","urlc":false,"urlctext":"","targetc":""}"


As you can see ["images"] or ["urls"] hold an array but the type is string! So I can't do $item->images->image_intro. I can't figure out what am I doing wrong or if it's normal? How can I get the value of image_intro in this case (only by using explode function?) or there is some line of code that I might forgot?

1 Answer 1


It is a json encoded string.

$images = json_decode($item->images);
  • Thank you David! So is it normal or anything is wrong with my code so I get it like that?
    – Mike
    Commented Sep 8, 2017 at 2:40
  • 1
    Just the way it is stored in the db. In other application you will see serialized data, but json is not language specific. You code looks fine. Commented Sep 8, 2017 at 4:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.