I'm trying to get all the paths from all the rows and to add them (after exploding) to one array (in order to present them as checkbox)
我试图从所有行获取所有路径并将它们(在爆炸后)添加到一个数组(以便将它们显示为复选框)
This is my code:
这是我的代码:
$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);
}
}
My output is like that:
我的输出是这样的:
Array ( [0] =>
Array ( [0] => [1] => my [2] => path )
[1] => Array ( [0] => [1] => another [2] => one )
How can i combine them to one array?
我怎样才能将它们组合成一个阵列?
I want to get something like this:
我想得到这样的东西:
Array ( [0] => [1] => my [2] => path [3] => another [4] => one )
Thank you!
谢谢!
2 个解决方案
#1
5
Take a look at the array_merge function:
看一下array_merge函数:
http://php.net/manual/en/function.array-merge.php
http://php.net/manual/en/function.array-merge.php
Use the following lines of code:
使用以下代码行:
$path = explode("/", $fpath);
$exp = array_merge($exp, $path);
HTH.
HTH。
#2
0
Check out array functions :
检查数组函数:
$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);
}
}
#1
5
Take a look at the array_merge function:
看一下array_merge函数:
http://php.net/manual/en/function.array-merge.php
http://php.net/manual/en/function.array-merge.php
Use the following lines of code:
使用以下代码行:
$path = explode("/", $fpath);
$exp = array_merge($exp, $path);
HTH.
HTH。
#2
0
Check out array functions :
检查数组函数:
$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);
}
}