I\'m trying to push objects into an array to end up with an object array like this:
[
{\"recipient_name\":\"John D\", \"phone_number\":\"123456\"},
{
You can directly write [] infront of message_recipients as below,
$myObjArray->message_recipients = [];
for ($j = 0; $j < $size; $j++) {
$myRecipientsObj = new stdClass; // created std class object
$myRecipientsObj->recipient_name = $myLargerArray[$j]['recipient_name'];
$myRecipientsObj->phone_number = $myLargerArray[$j]['phone_number'];
$myObjArray->message_recipients[] = $myRecipientsObj;
}
It should work.
Working demo