【发布时间】:2014-01-10 01:27:21
【问题描述】:
我正在自动生成一些代码并使用 var_export 以可解析格式输出数组。关于我如何让它缩进以使其与输出的其余部分匹配的任何想法
protected function getCode(){
$rs = ' $this->add(';
$rs .= var_export($this->getArray(),true);
$rs .= ');'.PHP_EOL;
return $rs;
}
我得到的输出是这样的
$this->add(array (
'name' => 'notes',
'attributes' =>
array (
'label' => 'Date',
'label_attributes' =>
array (
'class' => 'col-md-4 control-label',
),
),
));
我希望它带有正确的空白
$this->add(array (
'name' => 'notes',
'attributes' =>
array (
'label' => 'Date',
'label_attributes' =>
array (
'class' => 'col-md-4 control-label',
),
),
));
【问题讨论】:
标签: php string-formatting var-dump