Array of PHP Objects

后端 未结 5 1386
孤城傲影
孤城傲影 2020-12-02 06:29

So I have been searching for a while and cannot find the answer to a simple question. Is it possible to have an array of objects in PHP? Such as:

$ar=array()         


        
5条回答
  •  被撕碎了的回忆
    2020-12-02 06:53

    Although all the answers given are correct, in fact they do not completely answer the question which was about using the [] construct and more generally filling the array with objects.

    A more relevant answer can be found in how to build arrays of objects in PHP without specifying an index number? which clearly shows how to solve the problem.

提交回复
热议问题