This ought to be quite simple. I have crafted an SQL query that dumps all matching database table names for an array. I wish to print them out, yet for whatever reason I am unable to. Help! Thanks ahead of time.

Database tables are named: example_1, example_2, etc.

My code:

$sql = "SHOW TABLES LIKE 'example_%'";
$results = $wpdb->get_results($sql);

Carrying out a print_r($results) implies that all of the table names were effectively retrieved. Example output:

Array ( [0] => stdClass Object ( [Tables_in_wordpress (example_%)] => example_1 ) [1] => stdClass Object ( [Tables_in_wordpress (example_%)] => example_2 ) )

So i quickly attempted:

foreach($results as $res) {
  echo $res;
}

But no luck. How do i iterate through $leads to print each table title? Can there be something similar to $results[].value I possibly could use to retrieve the values?

In my opinion this really is what you ought to do:

$sql = "SHOW TABLES LIKE '%'";
$results = $wpdb->get_results($sql);

foreach($results as $index => $value) {
    foreach($value as $tableName) {
        echo $tableName . '<br />';
    }
}

The => will separate the important thing and cost from the multidimensional array.