473,322 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

What is the purpose of an array?

I've just finished reading Kevin Yank's book "Build Your Own Database Driven
Website", and I've not quite got a handle on the array variable.

Why do I need an array? Give me an example of an array in use, so that I can
understand why I'd want to store a bunch of stuff in one variable.
--
Joel Farris | Q: It reverses the logical flow of conversation.
twinkledust Designs | A: Why is top posting frowned upon?
http://twinkledust.com|
AIM chat: FarrisJoel | "John Kerry: A walking, talking contradiction"

Jul 17 '05 #1
5 4469
"Joel Farris" wrote:
I’ve just finished reading Kevin Yank’s book "Build Your
Own Database Driven
Website", and I’ve not quite got a handle on the array variable.

Why do I need an array? Give me an example of an array in use, so that I can
understand why I’d want to store a bunch of stuff in one
variable.


Joel,
There are a ton of resources on the net about php arrays. Try this
and you should find a ton of stuff:
http://www.google.com/search?sourcei...array+tutorial

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-purpose-...ict132976.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=444088
Jul 17 '05 #2
I noticed that Message-ID:
<SA*********************@bgtnsc04-news.ops.worldnet.att.net> from Joel
Farris contained the following:
I've just finished reading Kevin Yank's book "Build Your Own Database Driven
Website", and I've not quite got a handle on the array variable.

Why do I need an array? Give me an example of an array in use, so that I can
understand why I'd want to store a bunch of stuff in one variable.

A 'please' would be nice.

Say you have a number of inputs which you wish to validate. As you
validate each field it either passes or fails. If it fails you store
the field name in an array. At the end of the process you extract the
values in the array using a loop and display them.

The more code you write, the more obvious it will be.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
Geoff Berrow wrote:
A 'please' would be nice.
please() ;
Say you have a number of inputs which you wish to validate. As you
validate each field it either passes or fails. If it fails you store
the field name in an array. At the end of the process you extract the
values in the array using a loop and display them.

The more code you write, the more obvious it will be.

AHA! I was googling a bit and didn't really get a handle on it. I thought they
were saying that I should use arrays to store stuff in place of a database table
and I'm thinking, "Well, why shouldn't I just use a table?"

Your example makes it immediately obvious. Thanks.
--
Joel Farris | Q: It reverses the logical flow of conversation.
twinkledust Designs | A: Why is top posting frowned upon?
http://twinkledust.com|
AIM chat: FarrisJoel | "John Kerry: A walking, talking contradiction"

Jul 17 '05 #4
>> Say you have a number of inputs which you wish to validate. As you
validate each field it either passes or fails. If it fails you store
the field name in an array. At the end of the process you extract the
values in the array using a loop and display them.

The more code you write, the more obvious it will be.

AHA! I was googling a bit and didn't really get a handle on it. I thought they
were saying that I should use arrays to store stuff in place of a
database table
and I'm thinking, "Well, why shouldn't I just use a table?"


An array (especially an associative array) is a logical place to
PUT stuff from a database table after a query on the database while
you're getting ready to use the result. For example, mysql_fetch_row()
returns an array with the data from one row in it.

Also, some data is intermediate results and temporary: there's no
need to save anything but the final results, and many of the final
results go to the user's browser, not a database.

In some cases, you can think of an array (especially an associative
array, as PHP has) as an in-memory database. Consider things like
$_GET, $_PUT, $_SERVER, etc. With single variables you can't get
a list of which variables were passed. With a PHP array, you can.
The array $_SESSION is in-memory while it's being used, but between
pages, it gets saved somewhere else (a disk file is the default; I
prefer to use different session handlers to put it in a database
instead. Among other things, garbage collection is easier).
Your example makes it immediately obvious. Thanks.


Gordon L. Burditt
Jul 17 '05 #5
Joel Farris wrote:
Geoff Berrow wrote:
A 'please' would be nice.

please() ;
Say you have a number of inputs which you wish to validate. As you
validate each field it either passes or fails. If it fails you store
the field name in an array. At the end of the process you extract the
values in the array using a loop and display them.

The more code you write, the more obvious it will be.


AHA! I was googling a bit and didn't really get a handle on it. I
thought they were saying that I should use arrays to store stuff in
place of a database table and I'm thinking, "Well, why shouldn't I just
use a table?"


that will all depend on what you are going to do with the data. is it long term
information or short term and does it need to persist beyond the current viewing
of the page and need to remain server-side and not disclosed to the client.
there are ways to do this not using a database as well.

Your example makes it immediately obvious. Thanks.

--
Michael Austin.
Consultant - Available in 2-3 weeks.
Donations welcomed. Http://www.firstdbasource.com/donations.html
:)
Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Henning | last post by:
Hi grp! Trying to receive a udp msg in vb6, but it shows only zeros. What have I missed? /Henning -- Time is present only to prevent everything from happening at once. Still it seems that...
24
by: Romeo Colacitti | last post by:
Hi, Does anyone here have a strong understanding for the meanings of the terms "lvalue" and "rvalue" as it pertains to C, objects, and different contexts? If so please share. I've been...
53
by: Deniz Bahar | last post by:
I know the basic definition of a sequence point (point where all side effects guaranteed to be finished), but I am confused about this statement: "Between the previous and next sequence point an...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
17
by: SemSem | last post by:
i want to know waht is an index and how we use it with a simple example including the main of the program . thanx -- Islam Khalil,
30
by: Bill Reid | last post by:
#define MAX_VALUES 64 typedef struct { unsigned value_1; double value_2; double value_3; double value_4; } VALUES; typedef struct {
25
by: raylopez99 | last post by:
First in an occasional series. I'm somewhat experienced in C++, and am using .NET Visual Studio 2005 as the IDE. I'm learning C#. What I don't like about C#, compared to C++ (all flavors): ...
89
by: Tubular Technician | last post by:
Hello, World! Reading this group for some time I came to the conclusion that people here are split into several fractions regarding size_t, including, but not limited to, * size_t is the...
6
by: jason.cipriani | last post by:
I am reading the description of "generalized constant expressions" in C ++0x here: http://en.wikipedia.org/wiki/C%2B%2B0x#Generalized_constant_expressions And I don't understand the purpose of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shćllîpôpď 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.