V
V
V A2018-12-14 17:57:01
PHP
V A, 2018-12-14 17:57:01

How to deal with sessions and arrays in php?

Please do not throw slippers at me .. and explain in an accessible way.
I am a student and I am learning to program in a place where they don’t teach me this, so there are gaps in knowledge.
Can you please tell me how to do it so that the index of the value in the array is recorded in the session? Well, or something like that.
Declaration Output Now, when the session is output, the last element is displayed.
$nf = $_SESSION['number_flight'];
echo $nf;
5c13c4a7edb1a801357210.jpeg5c13c4b72248f266221068.jpeg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Skobkin, 2018-12-14
@skobkin

Break the task into subtasks and it will become easier for you to figure out how to solve each of them.
For example instead of:
Set tasks like this:
All items "learn", "understand", "understand" by and large will need to be done once for each atypical task. But if, instead of a complex perception of "do it well", you start to understand what is behind the technology on which you are trying to develop - you will start to really learn.
And questions like "how do I do this exactly" - they just teach you to repeat the code after people from Toster or StackOverflow without understanding what they are doing.
So understand how the web works in general: what is HTML and what is executed in the browser, what is PHP and what is executed on the server, how the browser sends data to the server, etc., etc.
As a result, you should fully understand how your page works and the paths through which data is transmitted from the moment the page is generated until the moment when you process the form received from the user and give him a success or error message.

G
gomer1726, 2018-12-14
@gomer1726

To write something to the session, the session array must be the first, that is, look, you are doing this
. And to write something to the session, you need to do this

//Будем надеяться что переменная $nf что нибудь содержит
$_SESSION['number_flight'] = $nf;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question