here is my code
if (($handle = fopen("example.csv", "r")) !== FALSE)
{
$row = 1;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE)
{
$prod_startid=1;
foreach ($Prod_op_reindex as $size_op_key => $size_op_value)
{
echo $prod_startid;
}
}
}
i want $prod_startid can Increment in foreach example: first time foreach the $prod_startid
will be 1 2 3 4,
then after while function,in foreach the $prod_startid
will be 5 6 7...
thanks everyone!
update: the arrays not the same,because some array have empty value ,so i have to use array_values function, for example:
Array ( [1] => XXS [2] => XS [3] => S [4] => M [5] => L [6] => XL [7] => XXL )
Array ( [1] => M [2] => L [3] => XL )
do you want this:
if (($handle = fopen("example.csv", "r")) !== FALSE) {
$row = 1;
$counter = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$prod_startid=$counter+1;
foreach ($Prod_op_reindex as $size_op_key => $size_op_value) {
echo $prod_startid;
$prod_startid++;
$couter = $prod_startid;
}
}
}
Is this what you want?
if (($handle = fopen("example.csv", "r")) !== FALSE) {
$row = 1;
$prod_startid = 0;
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
foreach ($Prod_op_reindex as $size_op_key => $size_op_value) {
$prod_startid++;
echo $prod_startid;
}
}
}