Reputation: 481
I am using this PHP Code:
($result["address1"] ? $result["address1"].' ' : '')
.($result["address2"] ? $result["address2"].' ' : '')
.($result["address3"] ? $result["address3"].' ' : '')
.($result["town"] ? $result["town"].' ' : '')
.($result["county"] ? $result["county"].' ' : '')
.($result["postcode"] ? $result["postcode"] : '')
after each line, i want to show a line break but not the HTML code.
using the above is displaying the
i have also tried using <br />
, \n
and \r
but they all show too
Upvotes: 0
Views: 58
Reputation: 6199
As mentioned earlier in comments, you could use something like the code below to achieve what you want:
$result["address1"] . PHP_EOL
Upvotes: 2
Reputation: 101
\n will work when wrapped in double-quotes, i.e. "\n", but it will not work when wrapped in single quotes, i.e. '\n'.
https://secure.php.net/manual/en/language.types.string.php
Upvotes: 2
Reputation: 2491
You could try something like this.
$output = null;
foreach($result AS $key => $value) {
if (!empty($result[$key])) {
$output .= $value.PHP_EOL;
}
}
echo $output;
Upvotes: 0