problem with multidimensional array does not take value

Asked

Viewed 32 times

1

 $dados= '{"nome":"teste","cpf":"teste"}';
 $value = json_decode($dados, TRUE);

foreach($value as $in)
{
$nome = $in->{'nome'};
$cpf = $in->{'cpf'};
}

i am trying to get the data, but the name value and Cpf comes null!!!

  • This is not a multidimencional array

1 answer

2

Try it this way:

$dados= '[{"nome":"teste","cpf":"teste"}]';
$value= json_decode($dados, TRUE);
foreach($vaue as $in)
{
  $nome = $in['nome'];
  $cpf $in['cpf']; 
}
  • that’s right, thank you!

  • @By following, mark as the right answer to help others who have the same question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.