Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
Calculate different permutations of prices using PHP

I'm working on a PHP script that needs to create a JSON file that includes an array of prices made up of a variety of other prices added together.

For example, I might have a base price of 50 and then a series of add-ons at 5, 10, 15, etc.

So my array would be a combination of all the possible ways those numbers can be added together, 50 + 5, 50 + 5 + 10, and so on.

I also then have a series of multipliers, 1, 3, 6, 12 which have to be multiplied by every number created by the previous step, 3 x (50 + 5), 6 x (50 + 5), and so on.

What I have so far (which involves using the Violet PHP streaming JSON encoder) works up to a certain point – about 16 add-ons – but after that, I get memory exhausted or max execution time errors.

I've tried bumping up the limits but that only works for another one or two extra add-ons and then I run into the same problem, and that's on my local version of the site where I can allocate as many resources as I like. I don't have that luxury on the server the site is hosted on.

I'm not sure it's worth posting the code I'm using at the moment because I think it probably has to be started over from scratch.

And I don't really know how to approach the task so that the script can confidently handle any number (within reason) of add-ons without the server running out of resources.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda