HI我的代碼不能正常工作,我得到的代碼時運行這個錯誤:PHP錯誤的參數不是數組錯誤
這是代碼的行110:
$results = array_merge($results, $game_list[$row][$col]);
這是代碼的其餘部分:
$results = array();
for ($row = 0; $row < $num_rows; $row++){
if (strstr($game_list[$row][2], $search) or strstr($game_list[$row][3], $search)){
for ($col = 0; $col < count($game_list[$row]); $col ++) {
$results = array_merge($results, $game_list[$row][$col]);
$successful = true;
}
}
}
if ($successful == true){
echo "<table>
<tr>
<th>Game ID</th>
<th>Genre</th>
<th>Game Name</th>
<th>Game Description</th>
<th>Rental Cost Per Day</th>
</tr>";
// Set number of table rows
$num_rows = count($results) - 1;
// Set number of table columns
$num_cols = 5;
// Start loop to generate rows
for($row = 0; $row < $num_rows; $row++) {
// Generate row HTML
echo "<tr>";
//Start loop to generate columns (nested FOR loop!)
for($col = 0 ; $col < $num_cols; $col++) {
// Generate column HTML
echo "<td>". $results[$row][$col] ."</td>";
}
// End of columns loop
// Generate end of row HTML
echo "</tr>";
}
echo "</table>";
的代碼旨在通過搜索數組game_list並查看用戶輸入的關鍵字是否在數組中。如果是,那麼代碼會將數組game_list中的整行添加到數組結果中。這個數組然後將顯示在一個表中給用戶。
如果有人能給我一個很好的解決方案。
好,'$ GAME_LIST [$行] [$山坳]'是一個字符串,不是一個數組。你爲什麼不簡單地做:'$ result [] = $ game_list [$ row];'? – Jeff