所以,我有一個數組是這樣的:Implode數組值?
Array
(
[0] => Array
(
[name] => Something
)
[1] => Array
(
[name] => Something else
)
[2] => Array
(
[name] => Something else....
)
)
是否有內爆值轉換成字符串的簡單方法,就像這樣:
echo implode(', ', $array[index]['name']) // result: Something, Something else, Something else...
不使用循環concate的值,如:
foreach ($array as $key => $val) {
$string .= ', ' . $val;
}
$string = substr($string, 0, -2); // Needed to cut of the last ', '
我不知道,`破滅()`? – 2011-01-31 18:24:57
@Rafe凱特勒:是的,但它只適用於一維陣列。 – BoltClock 2011-01-31 18:29:19