我正在尝试从所有行获取所有路径并将它们(爆炸后)添加到一个数组中(以便将它们显示为复选框)
这是我的代码:
$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 )
谢谢你!
看一下 array_merge 函数:
http://php.net/manual/en/function.array-merge.php http://php.net/manual/en/function.array-merge.php
使用以下代码行:
$path = explode("/", $fpath);
$exp = array_merge($exp, $path);
HTH.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)