I’ve been looking at the docs for quite some time but I can’t find a simple answer to my simple problem.
I have a bunch of values for in the $_SESSION array. I’ve found foreach and I can print (or do whatever) each value. How can I find the key name?
For example, I have $_SESSION[name]=”Bob” and $
foreach($_SESSION as $tempval) {
echo “His ” . $key . ” is ” . $tempval . “<br>”;
}
and have in result in…
His name is Bob
His phone is 555
My goal is to ultimately create JavaScript functions for each $_SESSION value, but I want to extract the key and the key’s value.
Can anyone help me out? Thanks!