S
S
Stanislav2019-02-12 17:06:23
PHP
Stanislav, 2019-02-12 17:06:23

PHP. How to change the value of an array through a form on the site?

Good day. I searched the Internet for examples, but I could not find anything similar.
What I need?
Let's say there are two files, namely index.php and an array file, for example array.php.
The array.php file containing the $array array is connected to index.php.
array.php contains:

$array = [
    'name'    => 'Название',
    'name2'  => 'Название 2'
];

How can I change a specific array value via input on a website?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
FanatPHP, 2019-02-13
@FanatPHP

Since this is a difficult task for those who write answers on the Toaster, I will give the full code

include "array.php";
$array['определенное значение'] = значение из формы;
$out = var_export($array, true);
file_put_contents("array.php","<?php\n\$array = $out;");

Z
zenaku, 2019-02-12
@zenaku

Through overwriting array.php as a normal file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question