"fartsniff" <fa**@sniff.com> wrote in message
news:vg************@corp.supernews.com...
I swear, these loops and for each's are going to kill me (if regex doesn't
first ;)
anyways, this is what i have:
if ($_POST['item_name1'] != "")
{
@$item_name1 = $_POST['item_name1'];
@$item_number1 = $_POST['item_number1'];
}
i am trying to come up with the best way (i.e. for each or something) to
process these.
basically, item_name can be anything from item_name1 to item_name99,
and i surely dont want to have a bunch of copy/pastes 99 times (or more,
the number depends on how much someone buys from me ;)
Why assign 99 values to 99 different variables when you could assign the
values to an array... one possible solution could be
foreach($_POST as $key=>$value)
{
$item_name[$key]="$value";
}
or perhaps better still
$item_name=$_POST;
Thus, if you have a form field named item_name1 which has a value "randell"
then you can print this element of the array like so:
print("item_name1 = $item_name[item_name1]");
or
$whatever=$item_name['item_name1'];
(note the single quotes)
Will that work?