How can I determine the current php array number -


good afternoon.

i'm attempting make array list 1 of key values being ($_request['qty#']), "#" current number of item within array (as pertains field in form gathers info).

for example:

$itemdetails =  array(     array(     'qty' => ($_request['qty1']),     'price' => 0.70,     'pn' => 'tv-1000',      array(     'qty' => ($_request['qty2']),     'price' => 0.99,     'pn' => 'tv-5000')); 

is there way can automatically have number in ($_request['qty']) determined without having type in numbers manually?

just wondering. next guess enter database , pull there.

thanks bunch in advance.

you need loop ...

$itemdetails = array(         array(                 'price' => 0.70,                 'pn' => 'tv-1000'         ),          array(                 'price' => 0.99,                 'pn' => 'tv-5000'         ) );  foreach ( $itemdetails $k => &$item ) {     $item['qty'] = $k + 1; } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -