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

298
Views
El contador de etiquetas BR incremental no funciona, falta algo

Tengo el siguiente código para agregar un contador incremental al lado de cada etiqueta BR, como un contador por línea para una canción con letra, pero no funciona. ¡Se agradece la ayuda!

 <?php $lyrics = "<p>Every time when I look in the mirror <br />All these lines on my face getting clearer <br /> The past is gone <br /> And it went by, like dusk to dawn <br /> Isn't that the way? <br /> Everybody's got their dues in life to pay <br /> Yeah, I know nobody knows <br /> Where it comes and where it goes <br /> I know it's everybody's sin <br /> You got to lose to know how to win <br /></p>"; $arr=explode(PHP_EOL, $lyrics); foreach($arr as $index=>$ele) { echo $ele . $index+1 . "<br />"; } ?>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Está intentando dividir la cadena $lyrics en la constante PHP_EOL (esta es una constante dependiente de la plataforma que se refiere a la línea que finaliza los usos de su sistema operativo). En su lugar, debe intentar dividir la cadena por <br /> .

about 4 years ago · Juan Pablo Isaza Report

0

Pruébelo de esta manera: use " <br /> " para separar y hacer que cada eco sea único:

 $lyrics = "<p>Every time when I look in the mirror <br />All these lines on my face getting clearer <br /> The past is gone <br /> And it went by, like dusk to dawn <br /> Isn't that the way? <br /> Everybody's got their dues in life to pay <br /> Yeah, I know nobody knows <br /> Where it comes and where it goes <br /> I know it's everybody's sin <br /> You got to lose to know how to win <br /></p>"; $arr=explode("<br />", $lyrics); foreach($arr as $index=>$ele) { echo $ele; echo $index+1; echo "<br />"; }
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!