我正在尝试从所有行获取所有路径并将它们(在爆炸后)添加到一个数组(以便将它们显示为复选框)
这是我的代码:
$result = mysql_query("select path from audit where ind=$ind");
$exp = array();
while($row = mysql_fetch_array($result))
{
foreach ($row as $fpath)
{
$path = explode("/", $fpath);
array_push($exp, $path);
}
}
我的输出是这样的:
Array ( [0] =>
Array ( [0] => [1] => my [2] => path )
[1] => Array ( [0] => [1] => another [2] => one )
如何将它们组合成一个阵列?
我想得到这样的东西:
Array ( [0] => [1] => my [2] => path [3] => another [4] => one )
谢谢!
答案 0 :(得分:7)
看一下array_merge函数:
http://php.net/manual/en/function.array-merge.php
使用以下代码行:
$path = explode("/", $fpath);
$exp = array_merge($exp, $path);
HTH。
答案 1 :(得分:0)
$result = mysql_query("select path from audit where ind=$ind");
$exp = array();
while($row = mysql_fetch_array($result))
{
foreach ($row as $fpath)
{
$path = explode("/", $fpath);
$exp = array_merge($exp, $path);
}
}