Form fields

I am trying to recieve information from another page but the form fields are numberered automaically. here is the sending page code

$i=1;

foreach($something as $this) {
$output = blah,blah...
$output = blah,blah...
$output = blah,blah...
$output = blah,blah...
$output =  '<input type="text" name="name_$i">';
$output = blah,blah...
$output = blah,blah...
$output = blah,blah...
$output = blah,blah...
$output = blah,blah...
$i++;
}

as you can see I know what name_1 field is but how do i get name_(last).

Does anyone have any information on this or can you give me a pointer for php.net

[code]<?php

$variable_0 = ‘’;
$variable_1 = ‘’;
$variable_2 = ‘’;
$variable_3 = ‘’;
$variable_4 = ‘’;
$variable_5 = ‘’;
$variable_6 = ‘’;
$variable_7 = ‘’;

function getlastvariablenumber($prefix, $start = 0){
$i = $start;
$found = false;
while ($found == false):
$current = $prefix . $i;
global $$current;
if (is_null($$current)):
$found = true;
$result = $i-1;
endif;
$i++;
endwhile;
return $result;
}

echo 'Result: ’ . getlastvariablenumber(‘variable_’);
// output:
// Result: 7
?>[/code]

Sponsor our Newsletter | Privacy Policy | Terms of Service