• 20-01-2021, 21:32:30
    #1
    herkese iyi forumlar arkadaşlar,
    trendyol api ile json formatında günlük data çekmekyetim, ancak color ve size değerlerini kaldırarak attributes array'inin içine aldılar,
    array içinde color ve size'ın ID değerleri mevcut ve ben sadece bu değerlerdeki bilgileri nasıl alırım, örnek kod aşağıda

                [6] => stdClass Object
                    (
                        [approved] => 1
                        [attributes] => Array
                            (
                                [0] => stdClass Object
                                    (
                                        [attributeId] => 47
                                        [attributeName] => Renk
                                        [attributeValue] => Vizon
                                    )
    
    
                                [1] => stdClass Object
                                    (
                                        [attributeId] => 346
                                        [attributeName] => Yaş Grubu
                                        [attributeValue] => Yetişkin
                                        [attributeValueId] => 4293
                                    )
    
    
                                [2] => stdClass Object
                                    (
                                        [attributeId] => 343
                                        [attributeName] => Cinsiyet
                                        [attributeValue] => Kadın / Kız
                                        [attributeValueId] => 4295
                                    )
    
    
                                [3] => stdClass Object
                                    (
                                        [attributeId] => 338
                                        [attributeName] => Beden
                                        [attributeValue] => 42
                                        [attributeValueId] => 5864
                                    )
    
    
                            )
    
    
                        [barcode] => MN2746SFNDR240742
    burada, [attributeId] => 47 nin altındaki [attributeValue] => Vizon kısmını ve [attributeId] => 338 deki [attributeValue] => 42 kısımlarını almak istiyorum,
    [attributeId] => 47 ve [attributeId] => 338 her zaman sabittir ancak [0], [1], [2], [3] sıralamaları değişmektedir onun alttaki kod ile alamıyorum
    $renk = $json['attributes]'][0]['attributeValue'];
    şimdiden yardımlarınız için teşekkürler..
  • 20-01-2021, 21:47:01
    #2
    function GetAttributeWithName($attributes,$name){
         foreach($attributes as $attribute):
             if($attribute->attributeName == $name)
                  return $attribute;
        endforeach;
        return null;
    }
    $renk = GetAttributeWithName($json['attributes'] ,"Renk");
    print_r($renk);
    $beden = GetAttributeWithName($json['attributes'] ,"Beden" );
    print_r($beden);
  • 20-01-2021, 22:08:13
    #3
    darness adlı üyeden alıntı: mesajı görüntüle
    function GetAttributeWithName($attributes,$name){
         foreach($attributes as $attribute):
             if($attribute->attributeName == $name)
                  return $attribute;
        endforeach;
        return null;
    }
    $renk = GetAttributeWithName($json['attributes'] ,"Renk");
    print_r($renk);
    $beden = GetAttributeWithName($json['attributes'] ,"Beden" );
    print_r($beden);
    Allah razı olsun hocam valla löp dedi oturdu yeminle çok çok teşekkürler.
  • 20-01-2021, 22:32:49
    #4
    ByMezarkabul adlı üyeden alıntı: mesajı görüntüle
    Allah razı olsun hocam valla löp dedi oturdu yeminle çok çok teşekkürler.
    rica ederim iyi çalışmalar