I have an array like this
$scope.kk = [
{ name:'Computer Architecture', price:65 },
{ name:'Advanced Composite Materials', price:45 },
{ name:'Stategies Unplugged', price:43 },
{ name:'Teaching Science', price:50 },
{ name:'Challenging Times', price:22 }];
I have passed this array to my controller through webapi like this
var req1= {
method: 'POST',
url: apiPoint.url + 'sin.php',
headers: {
'Content-Type': 'application/json'
},
params :{
"fulldet[]" : $scope.kk
}
$http(req1).then(function (response) {
if (response.data.status) {
alert(JSON.stringify(response.data));
}
}
And in my controller i need to extract this array I have used foreach statement like this
$result['ppp'] = $fulldet;
foreach($fulldet as $e){
$result['lm']=$e['name'];
}
But am getting ILLEGAL STRING OFFSET 'name'
Please help me.
For my reference i hv printed my array back after the response from controller. I get it like this
{"ppp":["
{\" name\":\"Computer Architecture\", \"price\":65 },
{\" name\":\"Advanced Composite Materials\", \"price\":45 },
{ \"name\":\"Stategies Unplugged\", \"price\":43 },
{\" name\":\"Teaching Science\", \"price\":50 },
{\" name\":\"Challenging Times\", \"price\":22 }"]}