After looping through a JSON object using foreach, the output is as follows:
{"Comment": {"id":"1","post_id":"31","created":"14263241"} , "User": {"fname":"Test","lname":"Test2"} }
{"Comment": {"id":"2","post_id":"32","created":"14263257"} , "User": {"fname":"Lionel","lname":"Messi"} }
The 'created' field in the JSON object represents a timestamp.
I am looking to add a new element in the second array based on a condition from another array. This will transform the array into:
{"Comment": {"id":"2","post_id":"32","created":"14263257"} , "User": {"fname":"Lionel","lname":"Messi"}, "Status":{"status":"add","userid":"10"} }
The content of
"Status":{"status":"add","userid":"10"}
will come from another JSON object.
Any assistance on accomplishing this task would be greatly appreciated.