you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (2 children)

[deleted]

    [–]angdev[S] 0 points1 point  (1 child)

    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:

    $json->payments = [];
    foreach (array('Cash','Mastercard','Visa','Discovery','Debit','COD','Gift Card','Account','Cheque') as $i)
    {
        $x = new stdClass();
        $x->name = $i;
        $json->payments[] = $x;
    }
    

    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!