我想Concat的作者名,當有一個文章,但由於某種原因,它增加了額外的逗號以上的作者。這是使用代碼IM:用於級聯添加額外的逗號
$get_coauthors = get_coauthors();
$count = count($get_coauthors);
if ($count > 1) {
for ($i = 0; $i <= $count; $i++) {
$name .= $get_coauthors[ $i ]->data->display_name . ' ,';
}
} else {
$name = $get_coauthors[0]->data->display_name;
}
error_log(print_r($name,true));
而我的print_r將返回user1 ,user2 , ,
任何IDEIA爲什麼?
請張貼的print_r的'結果($ get_coauthors)' –
不能肯定地說,沒有看到你的數據,但我要去猜測的一個作者命名爲空。 – Carcigenicate
你的循環比你的陣列和捉迷藏到一個一次出現較大的不存在'爲($ i = 0; $ I <= $計數; $ I ++){'它修改爲'爲($ I = 0; $我<$ count; $ i ++){'** Set'<?php error_reporting(E_ALL);函數ini_set(「display_errors設置」,1);'**,你會看到你的錯誤報道 – RiggsFolly