0

I'm querying a database through php and trying to store the result as a php array.

But when I echo $results and call the file in my browser, I just see "Array"

How can I see the results/whats inside of the array?

//find data as an associative array
$results = ORM::for_table('table_name')
            ->where('slug', 'slug_name')
            ->where('date', DATE>='2000-01-01')
            ->where('data', DATA)
            ->find_array();

echo $results
NewToJS
  • 2,011
  • 4
  • 35
  • 62

3 Answers3

1

use print_r($results) or var_dump($results)

Better approach to view on the browser would be

echo "<pre>" . print_r($results) . "</pre>";

or

echo "<pre>" . var_dump($results) . "</pre>";
DJ'
  • 1,760
  • 1
  • 13
  • 26
0

I use the following function to create a more readable dump.

function debug($v) {
    echo '<pre>';
    print_r($v);
    echo '</pre>';
}
Dave
  • 3,658
  • 1
  • 16
  • 9
0

the value of an array element can be another array, multidimensional, using the foreach shows each bucket contains the associative buckets slug, date, data

foreach($results as $result) {
 echo $result['slug'], '<br>';
 echo $result['date'], '<br>';
echo $result['data'], '<br>';
}