Mr-Bledi Mr-Bledi - 1 year ago 43
PHP Question

New element on a php array file

I'm a total noob on php, but a friend of mine asked for help and I thought I might do it..
I have this code/file here and want to find a way to add an element in this array via html file. I know it sounds noob, it does for me too, but please help, I've seen arrays, vectors and lists only on c++, tried to take a look at the documentation of php5 (since he want it in php 5) but I couldn't make it!

here it is...

$bledi = array('user12345', 'user2016', 'user5749852', 'user985658', 'HowToAddANewElement');
echo $result;

Answer Source
  • You need a form with a text input in HTML and a send button.

  • When the form is submitted to the action page there you could put your php.

  • You can make a global array ($bledi) and you will have an if condition there that says something like

          $bledi[] = $_REQUEST['input_text'];