return help with Json

0

How to return array with these results in php

 points 
 total  25779
 HTML   1793
 CSS    2666
 Design 216
 C# 0
 Databases  0

 $minhaarray [] = array(
        "points"=>$event->total,    
        "name"=>$category->name,
);
echo minhaarray ;

result obitido

   [{"points":"387","name":null},{"points":"1","name":null}, 
   {"points":"289","name":null},{"points":"1","name":null},
   {"points":"68","name":null},{"points":"290","name":null},
   {"points":"0","name":null},{"points":"116","name":null}] 

I need this result

   points :
  nome: 6548
  nome2:65774
  nome3:78587

 assim por diante

 igual a este resultado desta pagina https://teamtreehouse.com/ethanneff.json
    
asked by anonymous 12.11.2016 / 18:47

1 answer

1

Just do it from here:

$minhaarray['points'] = array(
        $category->name => $event->total 
);

echo json_encode($minhaarray, JSON_NUMERIC_CHECK);

But, pay attention to null values.

    
13.11.2016 / 03:35