how to add elements to an array in a loop using php

前端 未结 4 1417
失恋的感觉
失恋的感觉 2021-01-13 05:25

I am dynamically trying to populate a multidimensional array and having some trouble.

I have a list of US states. Associative array like this $states[nc], $states[sc

4条回答
  •  抹茶落季
    2021-01-13 06:09

    In PHP, you can fill an array without referring to the actual index.

    $newArray = array();
    foreach($var in $oldArray){
    $newArray[] = $var;
    }
    

提交回复
热议问题