我想不顯示[]數組=> mycod是我該怎麼讓陣列無需鑰匙
foreach ($results as $value=>$value2){ //for array $ resullt is array
$array2=print_r($value2);
return true;
}
Array ([0] => test [1] => test [2] => test [3] => test [4] => test)
我想不顯示[]數組=> mycod是我該怎麼讓陣列無需鑰匙
foreach ($results as $value=>$value2){ //for array $ resullt is array
$array2=print_r($value2);
return true;
}
Array ([0] => test [1] => test [2] => test [3] => test [4] => test)
試試這個:
echo implode("", $array);
不要使用print_r
再或者var_dump
對這一問題。只需設置$array2 = $value2;
要只能隨聲附和,你可以做到這一點的值:
foreach ($results as $key=>$value){ //for array $ resullt is array
echo $value . "<br />";
}
你不能有數組沒有鑰匙。
你可以通過循環訪問數組元素,並可以創建格式化輸出。像這樣:
$strOutput = "";
foreach ($results as $value=>$value2){
$strOutput .= $value2 ." ";
}
echo $strOutput;
閱讀有關數組的更多信息。數組將具有密鑰。您可以通過循環打印數組元素 –