I'm trying to use implode() in a script to return the result of an SQL query as a string so I can insert it into another table, however whenever I manage to get the implode to return anything it will only return a single result, even though the query returns more than one result.
Note: my PHP is not the strongest and I am using pre-existing code and reworking it, which is why a lot of the code will look like it's meant for a JSON API.
$rows = $stmt->fetchAll();
if ($rows) {
$response["success"] = 1;
$response["message"] = "Events Scheduled!";
$response["events"] = array();
foreach ($rows as $row) {
$post = array();
$post["id"] = $row["id"];
$post["message"] = $row["message"];
$post["pin"] = $row["pin"];
array_push($response["events"], $post);
$matstring=implode("', '",$post);
}
}
When echo'd out I get:
3', 'Test to check multiple entries are in array for when the check is made, this should be seen.', '12345
imploding $response['events'] returns "Array, Array" and everything else I have tried returns nothing. Where should I look to get the other entry?