Page 1 of 1

Custom HTML Array Index

Posted: Wed Jun 06, 2007 4:16 pm
by thomas777neo
Good Day

I would like to know how to change the html array index from the default value starting at 0 to a custom description.

For example, I have multiple text boxes that look like this

Code: Select all

<input type="text" id="vtl_intf_logicalpath[1]" name="vtl_intf_logicalpath[1]" value="00" size="2" maxlength="2" tabindex="9" class="swifttext" >
When iterating through the submitted results

Code: Select all

foreach ($_REQUEST["vtl_intf_logicalpath"] as $logical_id => $logical_value)
{
	echo "\$logical_id:$logical_id<br>";
	echo "\$logical_value:$logical_value<br>";
} // foreach ($_REQUEST["vtl_intf_logicalpath"] as $logical_id => $logical_value)
It outputs
$logical_id:0
$logical_value:00
$logical_id:1
$logical_value:01
$logical_id:2
$logical_value:02
I would like to change the array index ($logical_id) to another value starting from a custom number instead of 0

I did try this

Code: Select all

<input type="text" id="vtl_intf_logicalpath[1=>1]" name="vtl_intf_logicalpath[1=>1]" value="00" size="2" maxlength="2" tabindex="9" class="swifttext" >
But it still outputs the same results.

I also tried to find some examples on google to no avail. There are many examples of the default array, but not regarding the changing of the index.

Posted: Wed Jun 06, 2007 4:42 pm
by superdezign
Is there a reason for this...? I'm sure using foreach or something, it wouldn't cause a problem.
Then again, I've no idea what you need to change it for.

Posted: Wed Jun 06, 2007 9:10 pm
by feyd
You can name them whatever you wish. It's all arbitrary to PHP.