Good day.

There is a code that writes values ​​into an array, but with such an organization, the array is overwritten and only the latest data is entered into it.
Question: how do I change the code for the script to work?

$input = $dom->find('input[id="reg_username"]'); $fieldname = array('login' => $input[0]->name); $input = $dom->find('input[id="reg_email"]'); $fieldname = array('email' => $input[0]->name); var_dump($fieldname); 

Conclusion:

array (1) {['email'] => string (32) "some@email.ru"}

Thanks in advance!

    1 answer 1

    It is possible so:

     $fieldname = array(); $input = $dom->find('input[id="reg_username"]'); $fieldname['login'] = $input[0]->name; $input = $dom->find('input[id="reg_email"]'); $fieldname['email'] = $input[0]->name; 
    • So of course it works, but can you not then use the function array ()? - xenoll
    • array () - creates a new array. And you need to supplement the old one. <br> State your task in an understandable form if you want to get a reasonable answer - timka_s