开发者

Add values to one array after explode function

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!


Take a look at the array_merge function:

http://php.net/manual/en/function.array-merge.php

Use the following lines of code:

$path = explode("/", $fpath);
$exp = array_merge($exp, $path);

HTH.


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);
      }
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜