<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hi,</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Using MapScript PHP API, I want to create a label object (using tostring expression) and put 2 columns with a linebreak between them.</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="overflow-wrap: break-word; font-family: "Segoe UI"; FONT-FAMILY: Calibri, Helvetica, sans-serif">The example above is working well on a single line, but I don’t know how to make the linebreak (carriage return).</span><br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
$text = "(tostring([vol],'%.2f')+'[vol]')";</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
$classObj = new classObj($layer);<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
$classObj->setText($text);<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
$classObj->addLabel(CreateNewLabel($labelProperties));<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
I've tried multiple combination of \r\n but none of them work (map rendering work, but the label completely disappear).</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt;">$text = "(tostring([vol],'%.2f') + '\r\n[vol]')";</span><br>
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
$text = "(tostring([vol],'%.2f') + '\r\n' + '[vol]')";</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
If I don’t use the expression, the line break work</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
$text = "'[vol]\r\n[vol]'";<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
By the way, the TEXT property is on the classObj, the setText method doesn’t work on the labelObj.</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
With best regards,</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br style="overflow-wrap: break-word; font-family: "Segoe UI"">
</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
MapServer 7.4.4 (under ubuntu 16.04)</div>
<div style="overflow-wrap: break-word; font-size: 12pt; font-family: Calibri, Helvetica, sans-serif; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
PHP 5.6.40</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Jean-Philippe</div>
</body>
</html>