Hello everyone, help us with an example of a script for generating consecutive numbers from a specified range with repeating one number n-th number of times per column.

704 704 704 705 705 705 

etc.

From comments:

I am now preparing a file for bulk import of goods with the same attributes, prices, etc. in the cms opencard. In the OpenCard, the Options table is rendered into a separate component.

Desired result:
enter image description here

Closed due to the fact that the essence of the question is incomprehensible by the participants Vladimir Martyanov , aleksandr barakin , D-side , Grundy , katso 15 May '16 at 10:29 .

Try to write more detailed questions. To get an answer, explain what exactly you see the problem, how to reproduce it, what you want to get as a result, etc. Give an example that clearly demonstrates the problem. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    nothing is clear - splash58
  • If not difficult, decipher the phrase "with the repetition of one number n-th number of times in the column"? It would be great if you would bring what result you expect to see. - cheops
  • The range for generation is from 704 to 804. The number 704 should be generated (repeated) 10 times, followed by the next number 705, it is also generated 10 times, then the next one will not reach 804. and so
  • from a to b, n repetitions. so, what is next? You can not write two cycles - on the range and from 0 to n-1? The question is what? - splash58
  • one
    Page not found :) so you can - splash58

1 answer 1

Such problems are solved by a cycle.

a - the beginning of the segment , b - the end of the segment , n - the number of repetitions

 for ($i = $a; $i <= $b; $i++) { for($j = 0; $j<$n; $j++) echo "$i \n"; } 

The code is based on a cursory reading of the manual for php

  • $ a = 704, $ b = 804, $ i = 10? yes, but I never got it in a few hours - idicon
  • @ Identon that you do not understand? see - dirkgntly
  • and how to make echo in txt with / n? - Identon
  • In general, no, I would have been generally grateful for the code, 100 tabs are open, but there is no point - Identon
  • @ Idkonkon throw the code completely - dirkgntly