php - How to store multiple parameters passed as POST in database -
i have passed json encoded parameters post have captured , decoded in php file. have used following code that.
$entitybody = file_get_contents('php://input'); $entitybody = json_decode($entitybody, true);
i have passed json encoded parameters follows:
{ "id": "5", "name": "abcd", "imei": "1234" }
actually number of parameters passing post may 15 20 going insert in table i.e. each of them field in table in mysql database. new json , php. method know value of each parameter after checking whether set following:
if(isset($entitybody['id'])) ... elseif(isset(...)) ...
it clear there many if , else when there many parameters. there way can store parameters in table in more efficient way. if helps me in doing grateful.
use json_decode function parse json array or object.
$a = json_decode($entitybody); $a->id;
Comments
Post a Comment