First of all I'm sorry if this is a duplicate question but I couldn't find anything that would work and solve my problem.
I'm fetching data from a DB(Postgres) and parsing that into a Json array. The data looks like this
[{"login":"root@localhost","first_name":"Admin","last_name":"Name","title":null},{"login":"another@localhost","first_name":"More","last_name":"Data","title":"X"}]
My code to fetch this data is something like this:
foreach ($jsonData as $us) {
$user = new App\User;
$user->name = $us->login; //same thing for the rest of data
The error I'm getting says that I can't call data from the JSON with ->
but var_dump'ing $jsonData states that it's an array with all the correct elements in it.
PS: forgot to add but I tried var_dump($jsonData['login'][0]);
to get just the first login (should be "root@localhost") but it says "Undefined index: login"