How can I create n numbers of dynamic object using loop like :
$obj->data1 = $response1;
$obj->data2 = $response2;
$obj->data3 = $response3;
$obj->data4 = $response4;
and so on... I don't want to create array i want only object.
How can I create n numbers of dynamic object using loop like :
$obj->data1 = $response1;
$obj->data2 = $response2;
$obj->data3 = $response3;
$obj->data4 = $response4;
and so on... I don't want to create array i want only object.
$obj = new stdClass();
for($i=1;$i<=4;$i++)
$obj->{"data".$i}=${"response".$i};
You can change that loop to go as high as your actual number of variables.