I have got a simple function which outputs an array which i can then just "json_encode" This works fine. But now i need to do this multiple times.
while($row = mysql_fetch_assoc($resultsol)) {
$all[] = jsonoutput("$row[appid]");
}
But when i json_encode($all) this, it will have a first "header" sort of speak. Which i dont want.
What i get now (showing a sample part)
[
- {
- Firstentry: {
info1: "bla",
info2: "bla2",
cell {
color: "green",
But what i want is:
{
- Firstentry: {
info1: "bla",
info2: "bla2",
cell {
color: "green",
I see 2 possible sollutions, the json_encode should start 1 level deeper/lower (always mix those up) or the first array should be removed before the json_encode.
Either way, i am lost in between the 2. Any help would be appreciated.
UPDATE: added array output:
Good:
object(stdClass)#1 (1) { ["Firstentry"]=> object(stdClass)#2 (11) { ["info1"]=> string(3) "bla" ["info2"]=> string(3) "bla2"
Wrong:
array(63) { [0]=> object(stdClass)#1 (1) { ["Firstentry"]=> object(stdClass)#2 (10) { ["info1"]=> string(3) "bla" ["info2"]=> string(3) "bla2"
p.s. the function is called above jsonoutput, but this just outputs an array, i json_encode it in the end.