I am running an SQL Query in order to get the post IDs of the user currently logged in.
My query works as designed.
$userGadgets = $wpdb->get_results("SELECT item_id FROM mg_gd_mylist WHERE user_id = '$user_id'", ARRAY_A);
The issue I am facing has to do with the array returned.
array(
16
) {
[0]=> array(
1
) {
["item_id"]=> string(
5
) "10318" }
[1]=> array(
1
) {
["item_id"]=> string(
5
) "10378" }
[2]=> array(
1
) {
["item_id"]=> string(
5
) "10566" }
[3]=> array(
1
) {
["item_id"]=> string(
5
) "10608" }
[4]=> array(
1
) {
["item_id"]=> string(
5
) "10614" }
The model I am trying to produce is the following
Array
(
[0] => 140 //The item_id string as an integer
[1] => 141
[2] => 142
)
Any ideas on that one ? Thank you in advance.
Read more here: Array Formation – PHP