How can I get a PDO to return the data as a string not an array? I am not sure this is possible so if not is there a way to convert the array to a string after it has been processed?
My code which is returning the string is:
$result = $stmt->fetch(PDO::FETCH_ASSOC);
print_r($result);
I have tried different fetch types such as FETCH_CLASS
FETCH_OBJ
You can do it like this:
echo $stmt->fetchColumn();
Or:
$result = $stmt->fetch(PDO::FETCH_ASSOC);
echo $result[0];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With