如何在Symfony表单中将Array类型的数据作为TextArea获取? :
我试过了:
$suggest = $table->getSuggestion;
/* its format in database is :
s:378:"# first_suggest
# second_suggest
# third_suggest
*/
$suggest = preg_split("/# (.*)[\n\r]*/", $suggest, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$table->setSuggestion($suggest);
&安培;所以它在textarea字段中显示为:
#first suggestion
#second suggestion
#third suggestion
但在数据库中似乎如下:
a:8:{i:0;s:32:"first_suggest
";i:1;s:47:"second_suggest
";i:2;s:45:"third_suggest";}
表示:
array:42 [▼
0 => "first_suggest\r"
1 => "second_suggest \r"
2 => "third_suggest \r"
]
而不是:
a:8:{i:0;s:32:"first_suggest";i:1;s:47:"second_suggest";i:2;s:45:"third_suggest";}
&安培;我不知道这里的问题在哪里,你能帮我吗?!