Jump to content

Declaring session arrays...


jamesjmann

Recommended Posts

I was wondering if its possible to add new elements to anarray i have called "$_SESSION['error']" like this:

<?php
$_SESSION["errors"][] = "string";
?>

Because i have a whole bunch of if statements that check my registration form and currently, if an error is found, i add a new element to that array like this:

<?php
$_SESSION["errors"]["var"] = "string";
?>

Then i echo the form again with this:

<?php
Foreach ($_SESSION["error"] as $object => $value) {
echo $value;
}
?>

which basically just echos error messages...but the thing is is that i have a LOT of fields and its getting tiring having to give each error a unique name.

 

So is it possible to add new elements to this array like that? Do the array elements automatically get id's?

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.