我有数组块,
Array(
[0] => Array
(
[0] => "0"
[1] => "1"
[2] => "2"
)
[1] => Array
(
[3] => "3"
[4] => "4"
[5] => "5"
)
[2] => Array
(
[5] => "5"
[6] => "6"
[7] => "7"
)
)
我想用循环来破坏自动这个数组,并获得格式
012|345|567
答案 0 :(得分:3)
尝试使用implode + array_map:
$array = array ( array(1,2,3), array(4,5,6), array(7,8,9));
$array = implode('|', array_map('implode', $array));
print_r($array);
答案 1 :(得分:0)
你可以尝试一下。
function implode_array($param = array()) {
$result = '';
foreach ($param as $p1_key => $p1_value) {
$result .= implode("", $p1_value);
if ($p1_key < count($param))
$result .= '|';
}
return $result;
}
答案 2 :(得分:0)
尝试以下代码,
$array = Array(
[0] => Array
(
[0] => "0"
[1] => "1"
[2] => "2"
)
[1] => Array
(
[3] => "3"
[4] => "4"
[5] => "5"
)
[2] => Array
(
[5] => "5"
[6] => "6"
[7] => "7"
)
);
foreach($array as $key => $value) {
$keys[] = implode("",array_keys($value));
}
$result = implode('|', $keys);
谢谢!