Re: need help w a for loop
| From: | Colin Kettenacker | Date: | Mon, 20 Oct 2003 21:35:39 +0000 |
| Subject: | Re: need help w a for loop | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-166853@lists.php.net to get a copy of this message | ||
Hi Redmond,
A couple of issues I see here. First of all you are resetting the
$categories_array to an empty array for each iteration in the loop. You must
move it out of the loop. Secondly, you have enclosed the entire $_REQUEST
superglobal variable in quotes so it is seeing it as a string rather than a
superglobal.
Try this:
$categories_array = array();
for($j=0; $j < $categories_count; $j++){
$tempval="str_categories".$j;
array_push($categories_array,$_REQUEST[$tempval]);
}
ck
--
Cheap Domain Registration | Web Hosting | Email Packages | + more
Fantastic prices -- Even better service.
http://www.hosttohost.net
Redmond Militante r-militante@northwestern.edu on 10/20/03 2:15 PM wrote:
> hi all
>
> i'm in need of pointers on how to get the following for loop working correctly
>
> for($j=0; $j < $categories_count; $j++){
> $categories_array = array();
> $tempval="str_categories".$j;
> array_push($categories_array,'$_REQUEST['.$tempval.']');
> }
>
> it looks like it's appending the string '$_REQUEST['str_categories0']'
to the
> array $categories_array, instead of the actual value of
> $_REQUEST['str_categories0'] - the actual value is being passed correctly to
> the page because i can echo it out...
>
> any advice would be appreciated
>
> thanks
> redmond