How do I get an item from an array in PHP.
I have the following code:
<?php
if (isset($_POST['newUsers'])) {
$newUsers = $_POST['newUsers'];
foreach ($newUsers as $user) {
$usr = json_decode($user);
var_dump($user);
var_dump($usr);
echo($usr->nome);
echo($user->nome);
}
}
If I give a var_dump($user)
it returns:
string(38) "{\"nome\":\"alvaro\",\"idade\":\"34\"}"
and var_dump($usr)
returns NULL
.
The two echo()
does not show the name.
How do I get these data?