Well you could do

foreach ( $_POST as $var )
        ${$var} = ( isset($_POST[$var]) ? 1 : 0);

but that's really sloppy. If possible, I'd go more for something like

$vars = Array(
        'noPlatform',
        'littlePlatform',
        'lotsaPlatform',
        'yoMommasaPlatform');

foreach ( $vars as $v ) {
        ${$v} = ( isset($_POST[$v]) ? 1 : 0 );
}



On Wednesday 30 July 2003 06:50 pm, Ryan A wrote:
> Hi,
> I have a set of checkboxes (around 38) which will be sent to me via a
> post(eg: <input name="noPlatform" type="checkbox" id="noPlatform"
> value="1>)...if the checkbox is checked then session "noPlatform" should be
> created...AND only the checked ones should be registered all others should
> be unset.
>
> one way to do this would be to something like this:
> $noPlatform = (isset($_POST['noPlatform'])) ? 1 : 0;
> then set the session or via using a if and isset...
>
> but that would mean doing that for the whole 38 fields...I think I have
> seen something like this done via a loop (for, while or foreach or a
> combination) but cant find it in my old mail or the archive.
>
> Thanks in advance,
> -Ryan


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to