vendredi 30 juin 2017

Add property foreach object with php

I have two arrays object:

$seo_items      = collect($resource->items)->values();
$api_items      = collect($api_items)->values();

And, I want to iterate these elements and add the property size, which belongs to the $api_items array to the $seo_items array.

foreach($seo_items as &$seo_item)
                    {
                         foreach($api_items as $item) 
                         {

                            if($item->article_id == $seo_item->article->article_erp_id) 
                            {
                                 $seo_item->article->size == $item->size;
                                 $items_result[] = $seo_item;
                            }

                         }
                    }

The problem is that I can not assign this value, because php report this error:

Undefined property: stdClass::$size

How can I do this ?



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

Aucun commentaire:

Enregistrer un commentaire