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

210
Vistas
MySQL varchar and linebreak only works on textarea

I've got a DB entry with a varchar field with the following text saved:

This is a line
new line here
and another line here

I can only see those line breaks if I print it within textarea. How can I make the line break work outside of textarea?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

A sequence of multiple white space characters is collapsed by default in HTML, except in some elements like textarea inner text like you noticed. You have a few options:

  • Process your text to convert newlines to <br> tags (see nl2br())
  • Echo it to an element which preserve line breaks, such as an styled <pre>
  • Use CSS to set the white-space of your element to pre, pre-line or pre-wrap which will respect line breaks
over 4 years ago · Santiago Trujillo Denunciar
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