Is there a way to implode the values of similar objects contained in an array? I have an array of objects:
$this->inObjs
and I'd like a comma separated string of each of their messageID
properties:
$this->inObjs[$i]->messageID
Is there an elegant way to do this or am I going to have to MacGyver
a solution with get_object_vars
or foreachs
or something similar? Thanks for the help.
$allMessageID = '';
foreach ($this->inObjs as $objectDetail) :
$allMessageID[] = $objectDetail->messageID;
endforeach;
$allMessageID_implode = implode(",", $allMessageID);
echo $allMessageID_implode;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With