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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -