On 16 Aug 2008, at 17:03, tedd wrote:
I understand what you are saying -- semantics are important. But if
there is a need for temporary place to store values I don't consider
it bad form to store them in a numerically indexed array.
For example, if a user was going to purchase up to 10 items, I see
nothing wrong is using:
user_purchase[0] = $item0;
...
user_purchase[9] = $item9;
And as such, one can easily extract what the user purchased by
simply using for().
However, in this case I don't see the gain provided by using:
user_purchase['item1'] = $item0;
...
user_purchase['item9'] = $item9;
But that distinction would be required IF you were using SESSIONs.
And that's one of my points -- normal arrays come in two types and
the SESSION array don't.
I think you're missing the core of my point. My point only refers to
the root level of the $_SESSION array. I have no problem with using
numerically-indexed arrays elsewhere - I come from a C background so
it's where I started too and frequently use them.
However, in the example above you would not use...
$_SESSION[0] = $item0;
...
$_SESSION[9] = $item9;
Instead I assert you would have...
$_SESSION['user_purchase'][0] = $item0;
...
$_SESSION['user_purchase'][9] = $item9;
which is perfectly valid.
I'll try to re-word my basic point... I personally consider it bad to
even want to use numeric indexes at the root level of the $_SESSION
array because it creates data with no context in a globally accessible
location.
-Stut
--
http://stut.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php