In myLaravel endpoint, I’m aiming to incorporate newlines (n) within myresponse data while adhering to a specific structure. However, the literal n characters are printing directly instead of creating actual line breaks.
$string .= $request->lang === 'ar' ? ":اللوحات المتوفرة لدينا:n" : "Available plates:n";
$string .= "{" . $member->member_name . "}n";
$string .= "{" . $member->dynamic_links . "}n";
foreach ($ads as $rows) {
$plate_text = $request->lang === 'ar' ? ":لوحة السيارة" : "Car Plate:";
$plate_code = $request->lang === 'ar' ? $rows->plateCode->ar : $rows->plateCode->en;
$string .= $plate_text . " " . $rows->plate_number . " | " . $plate_code . ":n";
$string .= $rows->app_link . "n";
}
$this->response_status = true;
$this->response_code = '1001';
$this->response_description = 'Data Found';
$this->response_data = $string;
I have already tried to add PHP_EOL ,HTML line breaks and nl2br but nothing worked they also printing literal rn,br or n. The thing which i am expecting id to add a actual line break (new line) instead of printing literal n . I am testing this api in postman raw json and want something like this
Available plates:
{name of user}
{link of user}
{Car Plate {PLATE_NUNBER} | {PLATE_CODE}}:
{link}
However, my current API response looks like this:
"Available plates:n{abc}\n{link}\nCar Plate: 123| AB:nlink?plate_id=anCar Plate: 123| AB:nlinknCar Plate: 123| AB:nlink n"
As you can see, it includes the literal line break characters instead of actual newlines.
Could you please help me achieve the desired line breaks in my response?
7