Array to String Conversion PHP
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So as the title says i'm having an issue when trying to display the 5 results from my sql query i don't know how to convert them to an array, # Collection of SQL try { $sql = $conn->query("SELECT Channel_Location FROM channels ORDER BY RAND() Limit 5"); } catch(PDOException $e) { echo $sql . "<br>" . $e->getMessage(); } foreach($sql->fetchAll(PDO::FETCH_ASSOC) as $c) { echo $c . "<br>"; } $conn = null; I can't work out how to display the results, it displays one result if i change foreach($sql->fetchAll(PDO::FETCH_ASSOC) as $c) { to foreach(