Pergunta

I have a form where users can enter a sentence like so:

Quisque dictum, dolor sit amet consectetur egestas, metus turpis aliquam neque, et aliquet arcu sem ut lectus.

I need to write this to an image, i have done this using laravel and http://intervention.olivervogel.net/image image library.

The problem is that the area on the graphic is 100px by 100px, what would a sensible way of splitting the string into chunks and repositioning each "chunk" to fit within the 100px by 100px square. The image lib doesnt allow for new lines so i have to position each line.

Explode on the space delim then add up each array item to a fixed amount?

Foi útil?

Solução

Can you use wordwrap()?

And yes, that's essentially how it would work: split on spaces, joining the word until they exceed the allotted width, back up one word, then on to the next line.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top