2017-08-24 66 views
0
$allProfiles = ''; 
foreach(array_merge($profile, $otherProfiles) as $all): 
    $allProfiles .= $all; 
endforeach; 

echo "Player all profiles: $allProfiles"; 

這爲我打印Player all profiles: NameNameNameNameName,我該如何通過逗號內插?當我製作$allProfiles .= implode(",", $all);然後我得到了提前Invalid arguments passed in感謝PHP字符串implode:傳入的參數無效

編輯

只是改變$allProfiles .= $all;$allProfiles[] = $all;

則回波使用implode ..

+1

你可以做'$ allPrfiles [] = $ all;'在循環中,然後在底部implode:'echo「播放器所有配置文件:」.implode(',' ,$ allProfiles);'將'$ allPrfiles'設置爲頂部的數組,而不是空的。 – Rasclatt

+0

@Rasclatt是的..現在注意到了,謝謝;) – EvaldasL

回答

2

,並使陣列這樣

$allProfiles = array(); 
foreach(array_merge($profile, $otherProfiles) as $all): 
     $allProfiles[]= $all; 
endforeach; 

echo "Player all profiles: ".implode(",",$allProfiles); 
相關問題