Saturday 15 March 2014

php - Removing first array for json output -


I have found a simple function that produces an array that I can "json_encode" Works but now I have to do this many times.

  while ($ line = mysql_fetch_assoc ($ resultol)) {$ all [] = jsonoutput ("$ row [appid]"); }   

But when I have json_encode ($ all) this, it will have to say the first "header" type that I do not want

what I get now (Showing sample part)

  [- {--Firstantry: {info1: "bla", info2: "bla2", cell {color: "green",   

But what do I need:

  {- Firstentry: {info1: "bla", info2: "bla2", cell {color: "green", i see 2 possible sollutions , Json_encode should start level 1 / deep (always mixing those above) or the first array should be removed before json_encode Hey there. < 

Either way, I'm lost in the middle 2. Any help would be appreciated.

Update: Added array output:

Good:

  object (stdClass) # 1 (1) {["first"] = Gt; Object (stdClass) # 2 (11) {["info1"] = & gt; String (3) "Blay" ["info2"] = & gt; String (3) "bla2"   

incorrect:

  array (63) {[0] => Object (stdClass) # 1 (1) {["Firstentry"] = & gt; Object (stdClass) # 2 (10) {["info1"] = & gt; String (3) "Blay" ["info2"] = & gt; The string (3) "bla2"   

The PS function is said above from the jsonoutput, but it only produces an array, i json_encode at the end.

I solved it by changing it:

  while ($ line = Mysql_fetch_array ($ resultol)) {$ output = jsonoutput ("$ line [episode]"); $ All = array_merge ($ all, ($) $ output); }   

Then json_encode is doing

No comments:

Post a Comment