2
我var_dump
的变量$results
的说明是这样的提取值了stdClass的对象
array (size=11)
0 =>
object(stdClass)[69]
public 'Tables_in_database-name-here' => string 'wp_commentmeta' (length=14)
1 =>
object(stdClass)[68]
public 'Tables_in_database-name-here' => string 'wp_comments' (length=11)
2 =>
object(stdClass)[67]
public 'Tables_in_database-name-here' => string 'wp_links' (length=8)
...
10 =>
object(stdClass)[59]
public 'Tables_in_database-name-here' => string 'wp_users' (length=8)
我希望能在提取表名了上述的结构,并列出它们像这样的逗号分隔形式;
`wp_commentmeta,wp_comments,wp_links....,wp_users`
我得到了一个关于如何从这种结构中提取数据的脑冻结时刻。
我尝试了很多选择,因为你可以通过下面的代码来关注它 - 每个结尾的错误!
foreach ($results as $current_item):
/*
* $current_item is something like this:
*
* object(stdClass)[69]
public 'Tables_in_database-name-here' => string 'wp_commentmeta' (length=14)
*/
# echo $current_item;
# fires an error as "Catchable fatal error: Object of class stdClass could not be converted to string"
# echo $current_item[1];
# fires an error as "Cannot use object of type stdClass as array in..."
# echo array_values($current_item);
# fires an error as "array_values() expects parameter 1 to be array, object given in .."
# echo $current_item['Tables_in_database-name-here'];
#fires an error as "Cannot use object of type stdClass as array in "
how do you get that darn thing? :)
endforeach;
感谢您的代码..我现在看到的..是有办法避免在代码中使用硬编码“Tables_in_database名,在这里” - 由数字指的是它索引或类似的东西?我想避免使用该特定键的原因是,这应该是一个库函数... –
@AverageJoe我已经添加了一些更多的信息给我的答案 – Phil
甜..现在它完全独立... 谢谢... –