NYCPHP Meetup

NYPHP.org

[nycphp-talk] Creating multidimensional arrays

Emmanuel. M. Decarie emm at scriptdigital.com
Wed May 14 13:48:44 EDT 2003


Well, thinking more about it, I though that this might be more 
readable, and it might be faster too.

function assignValues2 ($groupID, $boutonID, $arSelection) {

	if ( isset ($arSelection[$groupID][$boutonID]) ) {
		return $arSelection[$groupID][$boutonID];
	} else {
		return '';
	}

}


$radioGroupDefaultValues = array ();
$radioGroupDefaultValues['1']['2'] = 'checked';
$radioGroupDefaultValues['2']['1'] = 'checked';
$radioGroupDefaultValues['3']['1'] = 'checked';

<hr>
<form>
Are you ugly?
Yes
<input type="radio" name="choice_1" value="1"
<?php echo assignValues2 (1, 1, $radioGroupDefaultValues) ?>>
No
<input type="radio" name="choice_1" value="1"
<?php echo assignValues2 (1, 2, $radioGroupDefaultValues) ?>>
<hr>
Are you tall?
Yes
<input type="radio" name="choice_2" value="1"
<?php echo assignValues2 (2, 1, $radioGroupDefaultValues) ?>>
No
<input type="radio" name="choice_2" value="1"
<?php echo assignValues2 (2, 2, $radioGroupDefaultValues) ?>>
<hr>
Are you funny?
Yes
<input type="radio" name="choice_3" value="1"
<?php echo assignValues2 (3, 1, $radioGroupDefaultValues) ?>>
No
<input type="radio" name="choice_3" value="1"
<?php echo assignValues2 (3, 2, $radioGroupDefaultValues) ?>>
</form>


Cheers
-Emmanuel
______________________________________________________________________
Emmanuel Décarie / Programmation pour le Web - Programming for the Web
Radio UserLand/Frontier - Perl - PHP - Javascript  <http://scriptdigital.com/>
Blog: <http://blog.scriptdigital.com> - AIM: scriptdigital


-- 
______________________________________________________________________
Emmanuel Décarie / Programmation pour le Web - Programming for the Web
Radio UserLand/Frontier - Perl - PHP - Javascript  <http://scriptdigital.com/>
Blog: <http://blog.scriptdigital.com> - AIM: scriptdigital




More information about the talk mailing list