我在foreach中有一个这样的变量
$variable=$variable1." ".$variable2;
输出为
apple fruit
tomato fruit
pineapple fruit
我想要的是
apple fruit
tomato fruit
pineapple fruit
如何实现?
答案 0 :(得分:1)
“ \ 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