Php Can';t从$wpdb加载一个值
我在wordpress db中有以下值: 没关系。将显示这些值。但在此之后,我需要执行如下foreach函数:Php Can';t从$wpdb加载一个值,php,arrays,wordpress,foreach,Php,Arrays,Wordpress,Foreach,我在wordpress db中有以下值: 没关系。将显示这些值。但在此之后,我需要执行如下foreach函数: foreach ($fasads_kitchen as $fasad_arg) { // an error is here if( have_rows($fasad_arg) ): ?>
foreach ($fasads_kitchen as $fasad_arg) {
// an error is here
if( have_rows($fasad_arg) ): ?>
while ( have_rows($fasad_arg) ) : the_row();
//something
}
但有一个错误:为foreach()提供的参数无效。。
我试着用
foreach ((array)$fasads_kitchen as $fasad_arg) {
但是调试器说它不是数组
它是字符串变量还是什么?如何解决这个问题
如果我正在使用
$fasads_kitchen = array('fasad_plastic','fasad_mdf') {}
它正在工作,但我需要从wpdb加载这些值。当您使用
$fasads_kitchen = $material->post_excerpt;
$fasads\u kitchen
需要是一个数组:
$fasads_kitchen = array();
foreach ($materials as $material) {
array_push($fasads_kitchen, $material->post_excerpt);
// or use one of the many ways to add to an array
}
然后您可以循环使用
$fasads\u kitchen
是的,我不知道如何将字符串转换为数组。非常感谢你。
$fasads_kitchen = array();
foreach ($materials as $material) {
array_push($fasads_kitchen, $material->post_excerpt);
// or use one of the many ways to add to an array
}