值添加到一个阵列后爆炸功能 [英] Add values to one array after explode function
本文介绍了值添加到一个阵列后爆炸功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从所有行获得所有的路径,并(以present他们作为复选框)添加它们(爆炸后),以一个阵列
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)
这是我的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 )
感谢您!
推荐答案
在array_merge功能请看下图:
Take a look at the array_merge function:
http://php.net/manual/en/function.array- merge.php
使用code以下行:
$path = explode("/", $fpath);
$exp = array_merge($exp, $path);
心连心。
这篇关于值添加到一个阵列后爆炸功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文