I’m trying to access a single time result stored in $_SESSION[‘pickup_time’]
When I ran this to find out what’s in the variable
echo var_dump($_SESSION['pickup_time']) . "<br />";
This is the results I’m getting
string(8) "07:30:00"
string(8) "07:30:00"
How do I put the value 07:30
in a variable called $userpickuptime
?
Updated for @tebe
echo '<pre>' , var_dump($_SESSION['pickup_time']) , '</pre>';
// init the var
$userpickuptime = $_SESSION['pickup_time'];
// and echo it
echo $userpickuptime;
Results as below
string(8) "06:30:00"
06:30:00
string(8) "06:30:00"
06:30:00
Eventually I only want 06:30
in $userpickuptime
Updated for @bobi
$userpickuptime = $_SESSION['pickup_time'];
echo $userpickuptime;
The results is
06:30:0006:30:00
What do I do so that only 06:30:00
is in $userpickuptime
?
This system isn’t developed by me. I’m not sure why it is executed twice 🙁
2
Answers
It looks like your code is simply executed twice. That’s the reason for the timestamp echoed two times.
It is also not required to
echo
avar_dump
, sincevar_dump
itself has no return value. So, it’s enough to do it this way.And regarding your question, how to put a value in a variable, you can do this like so.
since result from $_SESSION[‘pickup_time’] is 06:30:0006:30:00 you have 2 options
fix $_SESSION[‘pickup_time’] to return correct string time
split string and get the part you want
example
output