Associative Array in php -
i want use associative array, , want key , value key inserted loop. reason because size of array depend on no of keys, chosen user.
$i=$y; $totalrows=$x; $values=array(); for($a=0; $a<=$i; $a++){ $values[]= $i=>$totalrows; }
fyi $y , $x values generated "for" loop. value of user provided details html script.
to set key in associative array, use in variable definition.
$array['custom_key'] = 'some value';
to in loop, you'll have somehow unique key want each item in associative array while in loop.
for ($a = 0; $a <= $i; $a++) { $key = // key want item. $values[$key] = // set value key. }
Comments
Post a Comment