note 126552 added to class.jsonserializable

From: Date: Mon, 01 Nov 2021 22:46:38 +0000
Subject: note 126552 added to class.jsonserializable
Groups: php.notes 
Request: Send a blank email to php-notes+get-217135@lists.php.net to get a copy of this message
<?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' } ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 187.73.245.118) ---- Manual Page -- https://php.net/manual/en/class.jsonserializable.php Edit -- https://main.php.net/note/edit/126552 Del: integrated -- https://main.php.net/note/delete/126552/integrated Del: useless -- https://main.php.net/note/delete/126552/useless Del: bad code -- https://main.php.net/note/delete/126552/bad+code Del: spam -- https://main.php.net/note/delete/126552/spam Del: non-english -- https://main.php.net/note/delete/126552/non-english Del: in docs -- https://main.php.net/note/delete/126552/in+docs Del: other reasons-- https://main.php.net/note/delete/126552 Reject -- https://main.php.net/note/reject/126552 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#217135) next »