“php json obtenha valor por chave” Respostas de código

Leia o valor da chave JSON PHP

// json object.
    $contents = '{"firstName":"John", "lastName":"Doe"}';

    // Option 1: through the use of an array.
    $jsonArray = json_decode($contents,true);

    $key = "firstName";

    $firstName = $jsonArray[$key];


    // Option 2: through the use of an object.
    $jsonObj = json_decode($contents);

    $firstName = $jsonObj->$key;
Ivan The Terrible

php json obtenha valor por chave

// json object.
    $contents = '{"firstName":"John", "lastName":"Doe"}';

    // Option 1: through the use of an array.
    $jsonArray = json_decode($contents,true);

    $key = "firstName";

    $firstName = $jsonArray[$key];

// Option 2: through the use of an object.
    $jsonObject = json_decode($contents);

    $key = "firstName";

    $firstName = $jsonArray->$key;
Magsverge Solutions

Respostas semelhantes a “php json obtenha valor por chave”

Perguntas semelhantes a “php json obtenha valor por chave”

Mais respostas relacionadas para “php json obtenha valor por chave” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código