• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can you build an array with a for loop

#1
[eluser]ppwalks[/eluser]
I am trying to build an array to insert into db, I have a count and want to build the array according to the count so used a for loop, except it is only showing the last result of the array so could someone help with this please.

Code:
$count = count($_POST['cat_id']);

for ($i=1; $i<=$count; $i++)
  {
  $product = array( $i => $prod);
  }

The ouput to screen is:

( [7] => 126 )

when it should start from 1 and increment to 7 as a for loop should, where am i going wrong


Messages In This Thread
Can you build an array with a for loop - by El Forum - 08-08-2012, 10:33 AM
Can you build an array with a for loop - by El Forum - 08-08-2012, 10:54 AM
Can you build an array with a for loop - by El Forum - 08-08-2012, 11:01 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.