Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
php para bucle en la publicación

Estaba haciendo una sola publicación en mi código php. Quería usar php para. No funcionó para múltiples publicaciones. ¿Por qué no funcionó? No pude encontrar dónde está el error.

 <?php $e = $_POST['e']; $b = $_POST['b']; $y= $_POST['y']; $a = $_POST['a']; $e1 = $_POST['e1']; $b1 = $_POST['b1']; $y1= $_POST['y1']; $a1 = $_POST['a1']; for ($i=1; $i < 10 ; $i++) { if (!empty($a.$i)) { $package.$i['Description'] = 'nailce'; $packaging.$i['Code'] = '02'; $packaging.$i['Description'] = ''; $package.$i['Packaging'] = $packaging.$i; $unit.$i['Code'] = 'CM'; $unit.$i['Description'] = 'Centimeter'; $dimensions.$i['UnitOfMeasurement'] = $unit.$i; $dimensions.$i['Length'] = $e.$i; $dimensions.$i['Width'] = $b.$i; $dimensions.$i['Height'] = $y.$i; $package.$i['Dimensions'] = $dimensions.$i; $unit22['Code'] = 'KGS'; $unit22['Description'] = 'Kg'; $packageweight.$i['UnitOfMeasurement'] = $unit22; $packageweight.$i['Weight'] = $a.$i; $package.$i['PackageWeight'] = $packageweight.$i; $shipment['Package'][$i] = $package.$i; } } ?>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que has usado una forma incorrecta de nombrar variables variables . Puedes usar el siguiente código:

 <?php $e = $_POST['e']; $b = $_POST['b']; $y= $_POST['y']; $a = $_POST['a']; $e1 = $_POST['e1']; $b1 = $_POST['b1']; $y1= $_POST['y1']; $a1 = $_POST['a1']; for ($i=1; $i < 10 ; $i++) { $aVarName = 'a' . $i; if (!empty($$aVarName)) { $package = 'package' . $i; $packaging = 'packaging' . $i; $unit = 'unit' . $i; $dimensions = 'dimensions' . $i; $packageweight= 'packageweight' . $i; $bVarName = 'b' . $i; $eVarName = 'e' . $i; $yVarName = 'y' . $i; $$package['Description'] = 'nailce'; $$packaging['Code'] = '02'; $$packaging['Description'] = ''; $$package['Packaging'] = $$packaging; $$unit['Code'] = 'CM'; $$unit['Description'] = 'Centimeter'; $$dimensions['UnitOfMeasurement'] = $$unit; $$dimensions['Length'] = $$eVarName; $$dimensions['Width'] = $$bVarName; $$dimensions['Height'] = $$yVarName; $$package['Dimensions'] = $$dimensions; $unit22['Code'] = 'KGS'; $unit22['Description'] = 'Kg'; $$packageweight['UnitOfMeasurement'] = $unit22; $$packageweight['Weight'] = $$aVarName; $$package['PackageWeight'] = $$packageweight; $shipment['Package'][$i] = $$package; } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!