Question

in PHP imagettftext, should I be able to make line breaks with "\n" in a string like this?

// The text to draw
$text = 'Something\nElse';

When I try this, the text outputted reads "Something\\nElse" with 2 back slashes before the n.

This does not result in a line-break.

Firstly, SHOULD a single slash n make a line break (\n)?
Secondly, How do i get it to work?

Thanks

Was it helpful?

Solution

\n is a line break only when the string is delimited with double quotes.

echo 'Something\nElse';  // outputs Something\nElse
echo "Something\nElse";  // outputs Something
                         //         Else
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top