javascript - read json data in php -


i've created valid json object in javascript:

[     {         "code": "2f-58s",         "price": "123,13"     },     {         "code": "2f-58s",         "price": "123,13"     } ] 

i have problem reading in php:

$productsarr = json_decode($_get['object']); foreach($productsarr $article) {     $html .='<td>'.$article->code.'</td>';     $html .='<td>'.$article->price.'</td></tr>'; } 

i'm getting error foreach() loop not defined should be. missing in here?

edit:

it seems i'm not receiving entire json values method. i'm getting like: [{"code":"2f-58s","price":"123,13"},{"code":

edit2:

json object break happening when reading html tags object, error created when reach html tag: <p><strong>enmotion&nbsp;</strong></p>\n\n<p><strong>impulse</strong></p>

try this:

$productsarr = file_get_contents('php://input'); foreach($productsarr $article) {     $html .='<td>'.$article->code.'</td>';     $html .='<td>'.$article->price.'</td></tr>'; } 

Comments