所以,我有一个数组是这样的: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