i couldn't find replies question worked me. need add values array
via input
field. tried session
didn't work. when inspecting array print_r
every time array started again index [0]
overwriting former user input, not adding new value end. adding new values array standard way, declaring new value works perfectly:
$a = array(); $a[] = 5; $a[] = 'hello';
etc.
can give me hint?
thanks in advance danny
here go. first start session. create array if not exists in session array. add value of inputname
named field. second 1 checking, value in array, , if yes, not add again.
later, can access $_session['myarray']
on page.
do not forget start session on every page session_start();
use it.
<?php session_start(); //if session array not exists create 1 if (empty($_session['myarray'])) { $_session['myarray'] = array(); } if (!empty($_get['inputname'])) { $_session['myarray'][] = $_get['inputname']; } //if want check value of inputname exists, , add once: if (!empty($_get['inputname']) && !in_array($_get['inputname'], $_sessoion['myarray'])) { $_session['myarray'][] = $_get['inputname']; } ?> html starts here.
Comments
Post a Comment