Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda