i have an array containing query results to wordpress db:
$query = $wpdb->get_results("SELECT id, user_login, date, data1, data2 FROM table WHERE date >= 'date1' AND date <= 'date2'");
foreach ($query as $a) {
$array[] = array('id'=>$a->id, 'user_login'=>$a->user_login, 'date'=>$a->date, 'data1'=>$a->data1, 'data2'=>$a->data2);
}
next foreach loop to make strings for my needs i'm getting nothing, even
foreach ($array as $c) {
$d = $c->id;
}
echo $d;
returns Null. what am i doing wrong ?
$c
is an array not an object.
Try $d = $c["id"];
Wrong
$d = $c->id;
Right
$d = $c["id"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.