Answer the question
In order to leave comments, you need to log in
How to return data from ActiveRecord as an array of values, not objects?
return PathFile::find()->select('path')->where(['customer_id' => $this->customer_id])->asArray()->all();
[{"path":"........................"},{"path":".......... .."},{"path":"........."}]
Is there a built-in method to return data in the format: ["path":"........... .............", "path":"............", "path":"........."] or preferably ["........................","............", ".... ....."] ?
Answer the question
In order to leave comments, you need to log in
["........................","............", "...... ..."]
foreach
in your hands and in front of you with the song
For, if I understand correctly, you want to combine everything into 1 array (["........................ ","............", "........."])
but if you have the same keys - then the idea itself is bad... But thanks to the loop - you can transform the array as you like
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question