我正在为课堂做一个项目,我需要在城市州和zip变量之间添加一个空格。请帮忙!谢谢!
代码如下所示:
echo "<p>";
echo $weather['current_observation']['display_location']['city'];
echo $weather['current_observation']['display_location']['state'];
echo $weather['current_observation']['display_location']['country'];
echo $weather['current_observation']['display_location']['zip'];
echo "</p><p>";
echo $weather['current_observation']['observation_time_rfc822'];
echo "</p><p>";
echo $weather['current_observation']['weather'];
echo "</p><p>";
echo $weather['current_observation']['temperature_string'];
echo "</p><p>";
echo $weather['current_observation']['wind_string'];
echo "</p>";
答案 0 :(得分:6)
回显echo ' ';
。
或如通讯中所述:
“不需要一个不间断的空间。常规的
echo " ";
会很好。 - ceejayoz于2012年5月9日16:01”
答案 1 :(得分:3)
怎么样
echo $weather['current_observation']['display_location']['city'];
echo ' ';
echo $weather['current_observation']['display_location']['state'];
答案 2 :(得分:2)
你可以这样添加空格
echo $weather['current_observation']['display_location']['city'] . " ";
答案 3 :(得分:1)
您可以使用.
所以"foo" . "bar"
返回"foobar"
我会写
echo $weather['current_observation']['display_location']['city'] . ' ';
echo $weather['current_observation']['display_location']['state'] . ' ';
答案 4 :(得分:1)
最简单的方法:
echo " ";
如果那不是诀窍,那么你已经从问题中留下了重要的细节。
答案 5 :(得分:-1)
对于普通空间。
echo $weather['current_observation']['display_location']['city'] . " ";
echo $weather['current_observation']['display_location']['state'] . " ";
echo $weather['current_observation']['display_location']['country'] . " ";
echo $weather['current_observation']['display_location']['zip'] . " ";
或HTML间距。
echo $weather['current_observation']['display_location']['city'] . " ";
echo $weather['current_observation']['display_location']['state'] . " ";
echo $weather['current_observation']['display_location']['country'] . " ";
echo $weather['current_observation']['display_location']['zip'] . " ";