• 17-02-2019, 00:40:04
    #1
    Arkadaşlar json dan böyle bir cevap alıyorum. Bunu nasıl echo edebilirim.

    Array
    (
    [api] => Array
    (
    [results] => 45
    [countries] => Array
    (
    [1] => Algeria
    [2] => Argentina
    [3] => Australia
    [4] => Austria
    [5] => Belarus
    [6] => Belgium
    [7] => Brazil
    [8] => Bulgaria
    [9] => Canada
    [10] => Chile
    [11] => China
    [12] => Colombia
    [13] => Costa-Rica
    [14] => Croatia
    [15] => Denmark
    [16] => Ecuador
    [17] => Egypt
    [18] => England
    [19] => Finland
    [20] => France
    [21] => Germany
    [22] => Greece
    [23] => Honduras
    [24] => Iceland
    [25] => Italy
    [26] => Japan
    [27] => Luxembourg
    [28] => Mexico
    [29] => Morocco
    [30] => Netherlands
    [31] => Norway
    [32] => Paraguay
    [33] => Poland
    [34] => Portugal
    [35] => Russia
    [36] => Scotland
    [37] => Spain
    [38] => Sweden
    [39] => Switzerland
    [40] => Tunisia
    [41] => Turkey
    [42] => Uruguay
    [43] => USA
    [44] => Wales

    )

    )

    )
  • 17-02-2019, 02:19:28
    #2
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Çevrim içi çalıştırılabilir sürümü

    <?php
    
    $data = <<<JSON
    {
        "api": {
            "results": 45,
            "countries": [
                "Algeria",
                "Argentina",
                "Australia",
                "Austria",
                "Belarus",
                "Belgium",
                "Brazil",
                "Bulgaria",
                "Canada",
                "Chile",
                "China",
                "Colombia",
                "Costa-Rica",
                "Croatia",
                "Denmark",
                "Ecuador",
                "Egypt",
                "England",
                "Finland",
                "France",
                "Germany",
                "Greece",
                "Honduras",
                "Iceland",
                "Italy",
                "Japan",
                "Luxembourg",
                "Mexico",
                "Morocco",
                "Netherlands",
                "Norway",
                "Paraguay",
                "Poland",
                "Portugal",
                "Russia",
                "Scotland",
                "Spain",
                "Sweden",
                "Switzerland",
                "Tunisia",
                "Turkey",
                "Uruguay",
                "USA",
                "Wales"
            ]
        }
    }
    JSON;
    
    $json = json_decode( $data, true );
    
    foreach ( $json[ 'api' ][ 'countries' ] as $country ) {
        echo $country . PHP_EOL;
    }