Remove value "json header"

Asked

Viewed 192 times

3

I have a problem to generate a json in php, after the query it returns me this

{"37":{"codigo":"37","firstname":"Aluno","lastname":"Toledo","atividade":"A","checklist":null},
"1475":{"codigo":"1475","firstname":"Alzira","lastname":" Cabral","atividade":"A","checklist":"C"}}

has how I remove the "37" and the "1475"??

because I want to solve this problem, when I call it in an http.get by the angle, it is ordering by this "header" of the json...

2 answers

1


<?php

$array = json_decode('{"37":{"codigo":"37","firstname":"Aluno","lastname":"Toledo","atividade":"A","checklist":null},
                       "1475":{"codigo":"1475","firstname":"Alzira","lastname":" Cabral","atividade":"A","checklist":"C"}}', 1);

$result = array();   

foreach ($array as $key => $value) 
{
    $result[] = $value;
}

echo json_encode($result);
  • 1

    Thanks, it worked, perfect!

0

$array = json_decode('{"37":{"codigo":"37","firstname":"Aluno","lastname":"Toledo","atividade":"A","checklist":null},"1475":{"codigo":"1475","firstname":"Alzira","lastname":" Cabral","atividade":"A","checklist":"C"}}');

$array_without_keys = array_values($array);

echo json_encode($array_whitout_keys);

Browser other questions tagged

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