Why is the line break not inserted after the echo in the following case?

I have a line of code:

$value['street1'] = "MCN";
$value['street2'] = "Bhavani peth spur";
$value['city'] = "Los Angeles";
$value['state_code'] = "CA";
$value['zip_code'] = 90009;



$temp_rebate_data['user_address'] = $value['street1']."".($value['street2'] ? "\n".$value['street2'] : '')."\n".$value['city']."".$value['state_code']."-".$value['zip_code'];

echo $temp_rebate_data['user_address'];

die;

      

The output of the above code looks like this:

MCN Bhavani peth spur Los AngelesCA-90009

      

The expected output should be as follows:

MCN,
Bhavani peth spur,
Los Angeles, CA - 90009

      

Can someone please help me where I am doing wrong?

+3


source to share


2 answers


This should work for you:



$temp_rebate_data['user_address'] = $value['street1'].",".($value['street2'] ? "<br />".$value['street2'] . "," : '')."<br />".$value['city'].", ".$value['state_code']." - ".$value['zip_code'];

      

+3


source


just try using shift + enter for new line character in echo expression



0


source







All Articles