How do I fill an array inside a while loop and get new scope each iteration?

前端 未结 3 1392
死守一世寂寞
死守一世寂寞 2021-01-25 06:57

The problem is that I get only the last value comming from the Table. I think its because I am building the array while referencing its values to the same object, and it keeps c

3条回答
  •  孤独总比滥情好
    2021-01-25 07:25

    Try

    array_push(&$namesArray,$nameAndCode);
    

    I think array_push requires a reference or pointer.

    Is there a reason you aren't using $namesArray[]? Instead of the above:

    $namesArray[] = $nameAndCode;
    

提交回复
热议问题