我在表格中有这些行
K04,K84,K53,K331,L985
我如何处理数组爆炸以获得如下结果:
[&#39; K04&#39;&#39; K84&#39;&#39; K53&#39;&#39; K331&#39;&#39; 1985&#39;] < / p>
感谢您的帮助...
我试图使用爆炸,
$ex = explode (' ,' $myRowFromTable)
$co = count ($ex);
for ($i = 0; $i < $co; $i++)
{
echo $ex[$i];
}
结果仅显示K04
答案 0 :(得分:0)
如果您在$myRowFromTable
中将值作为字符串获取,则应尝试使用explode,如下所示:
$ex = explode (',', $myRowFromTable); //no space before comma
答案 1 :(得分:0)
好像你想将String转换为JavaScript Array。看看例子;
$myRowFromTable = 'K04, K84, K53, K331, L985';
// Has Array Data
$ex = explode (', ', $myRowFromTable);
// print_r($ex);
// According to User Expected Result
$newFormat = "['" . implode("', '", $ex) . "']";
echo $newFormat;