我正在为类做一个项目,我需要简单地在城市国家和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>";
在
要添加空格的任何回声线之后回显echo ' ';
。
或者如表彰中所述:
"不需要不间断的空间。定期
echo " ";
就可以了。– ceejayoz 五月 9 '12 在 16:01">
怎么样
echo $weather['current_observation']['display_location']['city'];
echo ' ';
echo $weather['current_observation']['display_location']['state'];
您可以使用 .
添加到字符串的末尾
所以"foo" . "bar"
回报"foobar"
我会写
echo $weather['current_observation']['display_location']['city'] . ' ';
echo $weather['current_observation']['display_location']['state'] . ' ';
您可以通过这种方式添加空格
echo $weather['current_observation']['display_location']['city'] . " ";
最简单的:
echo " ";
如果这不起作用,那么您已经遗漏了重要的细节。
对于正常空间,请执行。
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'] . " ";