Re: need loop help
| From: | Richard Lynch | Date: | Thu, 05 Oct 2006 20:53:07 +0000 |
| Subject: | Re: need loop help | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-242723@lists.php.net to get a copy of this message | ||
Change ${$fields[$j]} to $_POST[$fields[$j]] everywhere?
Or you could make the whole thing a lot more readable:
foreach($fields as $field){
$data[$field] = isset($_POST['field']) && $_POST['field'] ==
'on' ?
1 : 0;
}
On Tue, October 3, 2006 4:48 pm, Charles Kline wrote:
> hi all.
>
> i am trying to modify some old code and struggling a bit with this
> one:
>
> // returns an array of the names in the form post
> $fields = $_SESSION['case']->getComplaintKeys();
>
> // here is the array returned
> Array ( [0] => eligibility [1] => payment [2] => service [3] =>
> document [4] => licensing [5] => source [6] => date [7] => contact
> [8] => description [9] => status )
>
> for ($j = 0; $j < count($fields); $j++) {
> if (${$fields[$j]} == 'on') ${$fields[$j]} = 1;
> if (is_null(${$fields[$j]})) ${$fields[$j]} = 0;
> $data[$fields[$j]] = ${$fields[$j]};
> }
>
> The problem I am having is that the code is now on a more secure
> server with register_globals off (and I don't want to turn that on).
>
> I am not sure how to get the POST data sorted out using this method.
> Hope it is clear what I mean.
>
> Thanks,
> Charles
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?