0
for($n = 0; $n <= 5; $n++)
 {
    $some =   $n+1 ;
 }
    $dataSubActivity[]=array(
    'showSubid' => $some,
    'activityMainId'=> $activityMainId,
    'activitySubTitle'=> $activitySubTitle,
    'descSub'=> $description,
    'unit'=> $unit,
    'quantity'=> $quantity);

the above code is an array i want to increment "showSubid" by 1 so the result should be 1,2,3,4 etc please give some idea

2 Answers 2

1

Try:

for ($n = 0; $n <= 5; $n++) {
      // put it inside loop
      $dataSubActivity[]=array(
        'showSubid' => $n+1,
        'activityMainId'=> $activityMainId,
        'activitySubTitle'=> $activitySubTitle,
        'descSub'=> $description,
        'unit'=> $unit,
        'quantity'=> $quantity);
}
Sign up to request clarification or add additional context in comments.

Comments

1

USE THIS

for($n = 0; $n <= 5; $n++)
{
    $some =   $n+1 ;

    $dataSubActivity[]=array(
    'showSubid' => $some,
    'activityMainId'=> $activityMainId,
    'activitySubTitle'=> $activitySubTitle,
    'descSub'=> $description,
    'unit'=> $unit,
    'quantity'=> $quantity);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.