note 126552 deleted from class.jsonserializable by cmb

From: Date: Mon, 17 Jan 2022 23:14:33 +0000
Subject: note 126552 deleted from class.jsonserializable by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-217509@lists.php.net to get a copy of this message
Note Submitter: profissionaltec at gmail dot com ---- <?php class MyClass implements JsonSerializable... public function jsonSerialize() { return [ 'cd_foo' => $this->getCd_foo(), 'cd_bar' => $this->getCd_bar() ]; } ?> <?php //some interation... $arrayOfMyClass[$indice] = $myClassInstance->jsonSerialize(); ?> Result arrayOfMyClass[0] = { 'cd_foo':'data1', 'cd_bar':'data1' } arrayOfMyClass[1] = { 'cd_foo':'data2', 'cd_bar':'data2' } arrayOfMyClass[2] = { 'cd_foo':'data3', 'cd_bar':'data3' }

« previous php.notes (#217509) next »