我有一个数据库中的项目列表正在解析数组
Array
(
[0] => Array
(
[dToken] => 731fea87ea9dc61f16e93f1ad2b964bf1926633acac151c1853ab91ea0465228
[0] => 731fea87ea9dc61f16e93f1ad2b964bf1926633acac151c1853ab91ea0465228
)
[1] => Array
(
[dToken] => d890a5002f7da8bd35f6cae50e597d6f11554b26ba686bc7314afe77d1b36a61
[0] => d890a5002f7da8bd35f6cae50e597d6f11554b26ba686bc7314afe77d1b36a61
)
)
我需要获取所有dTokens并将它们列在一个变量中,每个dToken用逗号分隔,除了列表中的最后一个.
foreach($result as $device['dToken'] => $token){
//$devices = $token['dToken'];
print_r($token['dToken']);
}
有什么帮助吗?
解决方法:
你就在那里.
$tokens = array();
foreach($result as $device){
$tokens[] = $device['dToken'];
}
echo implode(',', $tokens);
标签:php,arrays,csv
来源: https://codeday.me/bug/20190723/1512143.html