Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 24th, 2007, 03:15 PM
Phil Latio
Guest
 
Posts: n/a
Default Putting an array within an array?

Still having fun trying to build the perfect form and validation classes and
wondered if anyone can help on the following.

In the following function, how can I make $validationparameters an array so
it can accept multiple values that I can iterate through? Don't need the
iteration part (yet).

function setField($type, $name, $value, $style, $label,
$validationparameter)
{
$this->number_of_fields++;
$this->fields[] = array('type'=>$type, 'name'=>$name, 'value'=>$value,
'style'=>$style, 'label'=>$label,
'validationparameters'=>$validationparameters);
}

This is part written function that I will use to pass the multiple values to
the array.

function setValidationParameters($number, $parameter)
{
$this->fields[$number][validationparameter] = $parameter;
}

I am beginning to confuse myself and wondering if anyone can add some sanity
to what I am doing.

Cheers

Phil




  #2  
Old August 24th, 2007, 03:35 PM
Phil Latio
Guest
 
Posts: n/a
Default Re: Putting an array within an array?

Ignore my post as I can't even type properly !!!

Cheers

Phil


  #3  
Old August 24th, 2007, 10:35 PM
Steve
Guest
 
Posts: n/a
Default Re: Putting an array within an array?


"Phil Latio" <phil.latio@f-in-stupid.co.ukwrote in message
news:RABzi.311528$tb2.204848@fe02.news.easynews.co m...
| Still having fun trying to build the perfect form and validation classes
and
| wondered if anyone can help on the following.

such an animal does not exist. ;^)

| This is part written function that I will use to pass the multiple values
to
| the array.
|
| function setValidationParameters($number, $parameter)
| {
| $this->fields[$number][validationparameter] = $parameter;
| }
|
| I am beginning to confuse myself and wondering if anyone can add some
sanity
| to what I am doing.

unless you are telling php that 'validationparater' should be interpreted as
a string value:

$this->fields[$number][validationparameter] = $parameter;

should be:

$this->fields[$number][$validationparameter] = $parameter;

however, where would it come from in that function. in either case, with the
code as-is as posted here, the value of the field with key $number will have
a blank array element and its value will be the value of the $parameter the
last time you called the function...which is probably not what you were
going for.

PLUS, please keep your casing consistent with best practices...either camel
case, pascal case, or underscore your variables:

$validationParameter;
$ValidationParameter;
$validation_parameter;

respectively.


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles