Ive made a mysql query using PDO like this
$timestamp_query = "SELECT timestamp FROM change_me;";
foreach ($conn->query($timestamp_query) as $times ) {
print_r($times);
echo "<br>";
}
But this is giving me back a set of arrays like this
Array ( [timestamp] => 2013-05-24 17:55:04 [0] => 2013-05-24 17:55:04 )
Array ( [timestamp] => 2013-05-24 18:00:05 [0] => 2013-05-24 18:00:05 )
Array ( [timestamp] => 2013-05-24 18:05:04 [0] => 2013-05-24 18:05:04 )
Why is this giving me 2 identical elements in each array, as opposed to just one ?
It returns an associative array to you so you can reference the results by either field name or index.
E.g. $times['timestamp'] or $times[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