PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 26, 2022

[FIXED] How to get json key as value instead string with json_encode function use

 July 26, 2022     json, php, string     No comments   

Issue

I am trying to convert php array to json using json_encode()

By using this I am getting [{"s":"simple2","value":"simple2","i":"img","u":"url","p":"520.000000"}]

Instead of key as string I wants this data in below format [{s:"simple2",value:"simple2",i:"img",u:"url",p:"520.000000"}]

How to get this type of data ? Is it possible to get this type data?


Solution

json_encode() will produce only a valid json format which is really the one it is producing. The one that you want is not a valid json format. You will have to apply text processing to get what you need. However, what is your final goal with the output of json array? Most languages that can can process json will accept the valid format.



Answered By - Mrigank Vallabh
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing