Sort array of objects by object fields

后端 未结 19 1591
情书的邮戳
情书的邮戳 2020-11-22 02:28

How can I sort this array of objects by one of its fields, like name or count ?

  Array
(
    [0] => stdClass Object
        (
          


        
19条回答
  •  后悔当初
    2020-11-22 03:15

    If you are using this inside Codeigniter, you can use the methods:

    usort($jobs, array($this->job_model, "sortJobs"));  // function inside Model
    usort($jobs, array($this, "sortJobs")); // Written inside Controller.
    

    @rmooney thank you for the suggestion. It really helps me.

提交回复
热议问题