Some days ago, I was just working on my old PHP project and I need to remove double quotes from JSON array keys because I want to add it to my chart. first of all, i just print my array but it shows as a string with double quotes in array keys. So chart does not appear on my dashboard. I just found what-what was an issue but at last, i just found what is an issue after a long time. It's crazy when sometime we have a small issue and taking too much time... hahaha, but finally, i got I need to remove double quotes from the key.
So if you have the same requirement or you want to remove double quotes from string jquery then you can do it easily by following small example code.
You can see by just copy and paste bellow code and run with your php file what you will get output.
Example:
<?php
$myJsonString = '{"id":"1", "name":"HD Topi", "from":"2012-01-01 09:00", "to":"2012-01-01 10:00"}';
$myJsonString = preg_replace('/"([^"]+)"\s*:\s*/', '$1:', $myJsonString);
print_r($myJsonString);
Output:
{id:"1", name:"HD Topi", from:"2012-01-01 09:00", to:"2012-01-01 10:00"}
I hope you found your best solution...
Do you like below Tutorials ?
- Angular Json Pipe Example | Json Pipe in Angular 9/8/7
- Angular Slice Pipe Example | Slice Pipe in Angular 9/8/7
- Angular Uppercase Pipe Example | Uppercase Pipe in Angular 9/8/7
- Angular LowerCase Pipe Example | LowerCase Pipe in Angular 9/8/7
- Angular Titlecase Pipe Example | Titlecase Pipe in Angular 9/8/7
- Angular KeyValue Pipe Example | KeyValue Pipe in Angular 9/8/7
- Call Method from One Component to Another Component in Angular
- Angular Push Object into Array Example