PHP 中变量之间的换行符
Line breaks between variables in PHP
我在 foreach 中有一个这样的变量
$variable=$variable1." ".$variable2;
输出为
apple fruit
tomato fruit
pineapple fruit
我想要的是
apple fruit
tomato fruit
pineapple fruit
如何实现?
"\t" 不是一个可行的选择,但@Magnus Eriksson 给出了很好的答案:
echo "\t".$var1."\t".$var2.PHP_EOL
:
apple fruit
tomato fruit
pineapple fruit
echo ' '.str_pad($var1,20," ").$var2.PHP_EOL
:
apple fruit
tomato fruit
pineapple fruit
我在 foreach 中有一个这样的变量
$variable=$variable1." ".$variable2;
输出为
apple fruit
tomato fruit
pineapple fruit
我想要的是
apple fruit
tomato fruit
pineapple fruit
如何实现?
"\t" 不是一个可行的选择,但@Magnus Eriksson 给出了很好的答案:
echo "\t".$var1."\t".$var2.PHP_EOL
:
apple fruit
tomato fruit
pineapple fruit
echo ' '.str_pad($var1,20," ").$var2.PHP_EOL
:
apple fruit
tomato fruit
pineapple fruit