Inline object/array creation?
Yes I searched:
- PHP.net docs (proof)
- Stackoverflow
- Yahoo
And did not find the answer.
In JavaScript I create an array of 5 objects like so:
this.pay_types =
[
{name:'Cash'},
{name:'Mastercard'},
{name:'Visa'},
{name:'Discovery'},
{name:'Debit'},
...
];
I can't find any help on how to do this in PHP without hundreds of lines of code and a for-loop lol. What am I missing here?
1 comments · 100% upvoted · other discussions
[deleted]
angdev [OP] 1 points · Sep 2015
I'm not sure I understand. I want to create an array of objects, not an object of arrays! The following code works but is fairly ugly:
And we only use PHP as a trampoline between JS and MySQL, we do not use PHP for any type of logic. I would get rid of PHP entirely if I could call MySQL directly from JS!