ConFoo Montreal 2026: Call for Papers

Voting

: max(two, one)?
(Example: nine)

The Note You're Voting On

rudie
7 years ago
If you want numerical ArrayObject objects to play nice with json_encode(), implement JsonSerializable:

class JsonSerializableArrayObject extends ArrayObject implements JsonSerializable {
function jsonSerialize() {
return $this->getArrayCopy();
}
}

For assoc ArrayObject objects this isn't neccesary, but for numerical arrays it is, otherwise they will be formatted like

{"0":"jaap","1":"karel"}

instead of

["jaap","karel"]

<< Back to user notes page

To Top