0

Im using angular as front end and php for backend. Angular array im sending through http

[{
name:'yogesh',
age :'30',
role:'developer'
}
]

but in php it is converted as

[
{ name:'yogesh'},
{age :'30'},
{role:'developer'}
]

1 Answers1

0

This is not a valid JSON. You have to pass a valid JSON and use json_decode in PHP to convert it to the array. Check the link and click on execute code to check result: http://sandbox.onlinephpfunctions.com/code/9b0e191862728cd444a9eb575564078d1e0af57d

$arr = '{
"name":"yogesh",
"age" :"30",
"role":"developer"
}';

$arr = json_decode($arr, true);

echo "<pre>";
print_r($arr);
Ankur Mishra
  • 1,284
  • 1
  • 6
  • 15